r56021 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56020‎ | r56021 | r56022 >
Date:09:35, 8 September 2009
Author:aaron
Status:ok
Tags:
Comment:
Minor code cleanup; avoids possible extra db query
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -264,7 +264,7 @@
265265 */
266266 public static function getPatrolLevel() {
267267 global $wgFlaggedRevsPatrolLevel;
268 - return intval($wgFlaggedRevsPatrolLevel);
 268+ return (int)$wgFlaggedRevsPatrolLevel;
269269 }
270270
271271 /**
@@ -737,8 +737,9 @@
738738 public static function updateStableVersion( $article, $rev, $latest = NULL ) {
739739 if( !$article->getId() )
740740 return true; // no bogus entries
741 - # Get the latest revision ID
742 - $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
 741+ # Get the latest revision ID if not set
 742+ if( !$latest )
 743+ $latest = $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
743744 # Get the highest quality revision (not necessarily this one)
744745 $dbw = wfGetDB( DB_MASTER );
745746 $maxQuality = $dbw->selectField( array('flaggedrevs','revision'),
@@ -753,7 +754,7 @@
754755 );
755756 # Get the timestamp of the edit after the stable version (if any)
756757 $revId = $rev->getId();
757 - if( $lastID != $revId ) {
 758+ if( $latest != $revId ) {
758759 # Get the latest revision ID
759760 $timestamp = $rev->getTimestamp();
760761 $nextTimestamp = $dbw->selectField( 'revision',
@@ -770,7 +771,7 @@
771772 $dbw->replace( 'flaggedpages',
772773 array( 'fp_page_id' ),
773774 array( 'fp_stable' => $revId,
774 - 'fp_reviewed' => ($lastID == $revId) ? 1 : 0,
 775+ 'fp_reviewed' => ($latest == $revId) ? 1 : 0,
775776 'fp_quality' => ($maxQuality === false) ? null : $maxQuality,
776777 'fp_page_id' => $article->getId(),
777778 'fp_pending_since' => $nextTimestamp ? $dbw->timestamp($nextTimestamp) : null ),
@@ -791,8 +792,9 @@
792793 $level = self::pristineVersions() ? FR_PRISTINE : FR_QUALITY;
793794 if( !self::qualityVersions() )
794795 $level = FR_SIGHTED;
795 - # Get the latest revision ID
796 - $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
 796+ # Get the latest revision ID if not set
 797+ if( !$latest )
 798+ $latest = $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
797799 $pageId = $article->getId();
798800 # Update pending times for each level
799801 $dbw = wfGetDB( DB_MASTER );
@@ -813,7 +815,7 @@
814816 if( $row ) {
815817 $id = intval( $row->fr_rev_id );
816818 # Get the timestamp of the edit after this version (if any)
817 - if( $lastID != $id ) {
 819+ if( $latest != $id ) {
818820 $nextTimestamp = $dbw->selectField( 'revision',
819821 'rev_timestamp',
820822 array( 'rev_page' => $pageId,

Status & tagging log