r44993 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44992‎ | r44993 | r44994 >
Date:23:59, 23 December 2008
Author:aaron
Status:ok (Comments)
Tags:
Comment:
* Don't rebuild the character size html twice
* Break lines so this code looks like a marginally better brand of a dog's breakfast
Modified paths:
  • /trunk/phase3/includes/ChangesList.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ChangesList.php
@@ -218,7 +218,8 @@
219219
220220 protected function insertTimestamp( &$s, $rc ) {
221221 global $wgLang;
222 - $s .= $this->message['semicolon-separator'] . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
 222+ $s .= $this->message['semicolon-separator'] .
 223+ $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
223224 }
224225
225226 /** Insert links to user page, user talk page and eventually a blocking link */
@@ -303,7 +304,7 @@
304305 $permission = ( $rc->mAttribs['rc_deleted'] & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED
305306 ? 'suppressrevision'
306307 : 'deleterevision';
307 - wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
 308+ wfDebug( "Checking for $permission due to $field match on {$rc->mAttribs['rc_deleted']}\n" );
308309 return $wgUser->isAllowed( $permission );
309310 } else {
310311 return true;
@@ -418,7 +419,8 @@
419420 $rc = RCCacheEntry::newFromParent( $baseRC );
420421
421422 # Extract fields from DB into the function scope (rc_xxxx variables)
422 - // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
 423+ // FIXME: Would be good to replace this extract() call with something
 424+ // that explicitly initializes variables.
423425 extract( $rc->mAttribs );
424426 $curIdEq = 'curid=' . $rc_cur_id;
425427
@@ -454,7 +456,8 @@
455457 } else if( $rc_type == RC_LOG ) {
456458 if( $rc_log_type ) {
457459 $logtitle = SpecialPage::getTitleFor( 'Log', $rc_log_type );
458 - $clink = '(' . $this->skin->makeKnownLinkObj( $logtitle, LogPage::logName($rc_log_type) ) . ')';
 460+ $clink = '(' . $this->skin->makeKnownLinkObj( $logtitle,
 461+ LogPage::logName($rc_log_type) ) . ')';
459462 } else {
460463 $clink = $this->skin->makeLinkObj( $rc->getTitle(), '' );
461464 }
@@ -495,7 +498,8 @@
496499 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
497500 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
498501 $aprops = ' tabindex="'.$baseRC->counter.'"';
499 - $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $querycur, '' ,'', $aprops );
 502+ $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(),
 503+ $this->message['cur'], $querycur, '' ,'', $aprops );
500504
501505 # Make "diff" an "cur" links
502506 if( !$showdifflinks ) {
@@ -507,7 +511,8 @@
508512 }
509513 $diffLink = $this->message['diff'];
510514 } else {
511 - $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $querydiff, '' ,'', $aprops );
 515+ $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
 516+ $querydiff, '' ,'', $aprops );
512517 }
513518
514519 # Make "last" link
@@ -614,7 +619,8 @@
615620 array_push( $users, $text );
616621 }
617622
618 - $users = ' <span class="changedby">[' . implode( $this->message['semicolon-separator'], $users ) . ']</span>';
 623+ $users = ' <span class="changedby">[' .
 624+ implode( $this->message['semicolon-separator'], $users ) . ']</span>';
619625
620626 # ID for JS visibility toggle
621627 $jsid = $this->rcCacheIndex;
@@ -708,8 +714,9 @@
709715 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
710716 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
711717 foreach( $block as $rcObj ) {
712 - # Get rc_xxxx variables
713 - // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
 718+ # Extract fields from DB into the function scope (rc_xxxx variables)
 719+ // FIXME: Would be good to replace this extract() call with something
 720+ // that explicitly initializes variables.
714721 extract( $rcObj->mAttribs );
715722
716723 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
@@ -828,8 +835,9 @@
829836 */
830837 protected function recentChangesBlockLine( $rcObj ) {
831838 global $wgContLang, $wgRCShowChangedSize;
832 - # Get rc_xxxx variables
833 - // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
 839+ # Extract fields from DB into the function scope (rc_xxxx variables)
 840+ // FIXME: Would be good to replace this extract() call with something
 841+ // that explicitly initializes variables.
834842 extract( $rcObj->mAttribs );
835843 $curIdEq = "curid={$rc_cur_id}";
836844
@@ -852,13 +860,14 @@
853861 }
854862 # Diff and hist links
855863 if ( $rc_type != RC_LOG ) {
856 - $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
857 - $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
 864+ $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
 865+ $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ),
 866+ $curIdEq.'&action=history' ) . ')';
858867 }
859868 $r .= ' . . ';
860869 # Character diff
861 - if( $wgRCShowChangedSize ) {
862 - $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ;
 870+ if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
 871+ $r .= "$cd . . ";
863872 }
864873 # User/talk
865874 $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;

Follow-up revisions

RevisionCommit summaryAuthorDate
r45194Cleanup to r44993 -- avoid using '$x = foo()' in an if() condition on general...brion18:43, 30 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   18:45, 30 December 2008

On general principle I broke the ($cd = $rcObj->getCharacterDifference() out of the if() condition in r45194

Status & tagging log