r75321 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75320‎ | r75321 | r75322 >
Date:17:09, 24 October 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Explicit class variable definition. Swap some while loops for foreach. Couple of braces
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -2,6 +2,8 @@
33 if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 class CodeRevision {
 6+ public $mRepoId, $mRepo, $mId, $mAuthor, $mTimestamp, $mMessage, $mPaths, $mStatus, $mOldStatus, $mCommonPath;
 7+
68 public static function newFromSvn( CodeRepository $repo, $data ) {
79 $rev = new CodeRevision();
810 $rev->mRepoId = $repo->getId();
@@ -27,8 +29,9 @@
2830 $compare = explode( '/', $path['path'] );
2931
3032 // make sure $common is the shortest path
31 - if ( count( $compare ) < count( $common ) )
 33+ if ( count( $compare ) < count( $common ) ) {
3234 list( $compare, $common ) = array( $common, $compare );
 35+ }
3336
3437 $tmp = array();
3538 foreach ( $common as $k => $v ) {
@@ -366,8 +369,10 @@
367370 // Send message in receiver's language
368371 $lang = array( 'language' => $user->getOption( 'language' ) );
369372 $user->sendMail(
370 - wfMsgExt( 'codereview-email-subj2', $lang, $this->mRepo->getName(), $this->getIdString( $row->cr_id ) ),
371 - wfMsgExt( 'codereview-email-body2', $lang, $committer, $this->getIdStringUnique( $row->cr_id ), $url, $this->mMessage, $rowUrl )
 373+ wfMsgExt( 'codereview-email-subj2', $lang, $this->mRepo->getName(),
 374+ $this->getIdString( $row->cr_id ) ),
 375+ wfMsgExt( 'codereview-email-body2', $lang, $committer,
 376+ $this->getIdStringUnique( $row->cr_id ), $url, $this->mMessage, $rowUrl )
372377 );
373378 }
374379 }
@@ -595,7 +600,7 @@
596601 __METHOD__
597602 );
598603 $users = array();
599 - while ( $row = $res->fetchObject() ) {
 604+ foreach( $res as $row ) {
600605 $users[$row->cc_user] = User::newFromId( $row->cc_user );
601606 }
602607 return $users;
@@ -615,7 +620,7 @@
616621 ),
617622 __METHOD__
618623 );
619 - while ( $row = $res->fetchObject() ) {
 624+ foreach( $res as $row ) {
620625 if ( $this->mId != intval( $row->cr_id ) ) {
621626 $refs[] = $row;
622627 }

Comments

#Comment by 😂 (talk | contribs)   15:55, 6 November 2010

Maybe instead of making all those public we could see if they could be protected or private as needed ;-)

Status & tagging log