r67964 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67963‎ | r67964 | r67965 >
Date:21:48, 13 June 2010
Author:aaron
Status:deferred
Tags:
Comment:
* Redid pending file/template checks. (bug 23415)
* Format fi_img_timestamp/fr_img_timestamp values for DB. Trim garbage.
* Moved stableVersionIsSynced() to FlaggedArticle.
* Made file page sync check work (comparing stable to current upload version).
* Fixed parsing in approveRevision(): it was missing the rev ID.
* Fixed tab highlighting for when only templates/files not synced.
* Removed bogus "show all pending changes" links from diffs.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -9,6 +9,7 @@
1010 protected $stableRev = null;
1111 protected $pendingRevs = null;
1212 protected $pageConfig = null;
 13+ protected $file = null;
1314
1415 /**
1516 * Get a FlaggedArticle for a given title
@@ -40,9 +41,26 @@
4142 $this->stableRev = null;
4243 $this->pendingRevs = null;
4344 $this->pageConfig = null;
 45+ $this->file = null;
4446 parent::clear();
4547 }
4648
 49+ /**
 50+ * Get the current file version of this file page
 51+ * @TODO: kind of hacky
 52+ * @return mixed (File/false)
 53+ */
 54+ public function getFile() {
 55+ if ( $this->getTitle()->getNamespace() != NS_FILE ) {
 56+ return false; // not an file page
 57+ }
 58+ if ( is_null( $this->file ) ) {
 59+ $imagePage = new ImagePage( $this->getTitle() );
 60+ $this->file = $imagePage->getFile();
 61+ }
 62+ return $this->file;
 63+ }
 64+
4765 /**
4866 * Is the stable version shown by default for this page?
4967 * @param int $flags, FR_MASTER
@@ -132,6 +150,100 @@
133151 }
134152
135153 /**
 154+ * Check if the stable version is synced with the current revision.
 155+ * Note: This function can be pretty expensive...
 156+ * @param ParserOutput $stableOutput, will fetch if not given
 157+ * @param ParserOutput $currentOutput, will fetch if not given
 158+ * @return bool
 159+ */
 160+ public function stableVersionIsSynced(
 161+ ParserOutput $stableOutput = null, ParserOutput $currentOutput = null
 162+ ) {
 163+ global $wgUser, $wgMemc, $wgEnableParserCache, $wgParserCacheExpireTime;
 164+ $srev = $this->getStableRev();
 165+ if ( !$srev ) {
 166+ return true;
 167+ }
 168+ # Stable text revision must be the same as the current
 169+ if ( $this->revsArePending() ) {
 170+ return false;
 171+ # Stable file revision must be the same as the current
 172+ } elseif ( $this->getTitle()->getNamespace() == NS_FILE ) {
 173+ $file = $this->getFile(); // current upload version
 174+ if ( $file && $file->getTimestamp() > $srev->getFileTimestamp() ) {
 175+ return false;
 176+ }
 177+ }
 178+ # If using the current version of includes, there is nothing else to check.
 179+ if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_CURRENT ) {
 180+ return true; // short-circuit
 181+ }
 182+ # Try the cache...
 183+ $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $this->getId() );
 184+ $value = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $this );
 185+ if ( $value === "true" ) {
 186+ return true;
 187+ } elseif ( $value === "false" ) {
 188+ return false;
 189+ }
 190+ # If parseroutputs not given, fetch them...
 191+ if ( is_null( $stableOutput ) || !isset( $stableOutput->fr_newestTemplateID ) ) {
 192+ # Get parsed stable version
 193+ $anon = new User(); // anon cache most likely to exist
 194+ $stableOutput = FlaggedRevs::getPageCache( $this, $anon );
 195+ if ( $stableOutput == false && $wgUser->getId() ) {
 196+ $stableOutput = FlaggedRevs::getPageCache( $this, $wgUser );
 197+ }
 198+ # Regenerate the parser output as needed...
 199+ if ( $stableOutput == false ) {
 200+ $text = $srev->getRevText();
 201+ $stableOutput = FlaggedRevs::parseStableText( $this, $text, $srev->getRevId() );
 202+ # Update the stable version cache
 203+ FlaggedRevs::updatePageCache( $this, $anon, $stableOutput );
 204+ }
 205+ }
 206+ if ( is_null( $currentOutput ) || !isset( $currentOutput->fr_newestTemplateID ) ) {
 207+ # Get parsed current version
 208+ $parserCache = ParserCache::singleton();
 209+ $currentOutput = false;
 210+ $anon = new User(); // anon cache most likely to exist
 211+ # If $text is set, then the stableOutput is new. In that case,
 212+ # the current must also be new to avoid sync goofs.
 213+ if ( !isset( $text ) ) {
 214+ $currentOutput = $parserCache->get( $this, $anon );
 215+ if ( $currentOutput == false && $wgUser->getId() ) {
 216+ $currentOutput = $parserCache->get( $this, $wgUser );
 217+ }
 218+ }
 219+ # Regenerate the parser output as needed...
 220+ if ( $currentOutput == false ) {
 221+ global $wgParser;
 222+ $source = $this->getContent();
 223+ $options = FlaggedRevs::makeParserOptions( $anon );
 224+ $currentOutput = $wgParser->parse( $source, $this->getTitle(),
 225+ $options, /*$lineStart*/true, /*$clearState*/true, $this->getLatest() );
 226+ # Might as well save the cache while we're at it
 227+ if ( $wgEnableParserCache ) {
 228+ $parserCache->save( $currentOutput, $this, $anon );
 229+ }
 230+ }
 231+ }
 232+ # Since the stable and current revisions have the same text and only outputs,
 233+ # the only other things to check for are template and file differences in the output.
 234+ # (a) Check if the current output has a newer template/file used
 235+ # (b) Check if the stable version has a file/template that was deleted
 236+ $synced = (
 237+ !$stableOutput->fr_includeErrors && // deleted since
 238+ FlaggedRevs::includesAreSynced( $stableOutput, $currentOutput )
 239+ );
 240+ # Save to cache. This will be updated whenever the page is touched.
 241+ $data = FlaggedRevs::makeMemcObj( $synced ? "true" : "false" );
 242+ $wgMemc->set( $key, $data, $wgParserCacheExpireTime );
 243+
 244+ return $synced;
 245+ }
 246+
 247+ /**
136248 * Is this page less open than the site defaults?
137249 * @return bool
138250 */
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -735,102 +735,31 @@
736736 # ################ Synchronization and link update functions #################
737737
738738 /**
739 - * @param FlaggedRevision $srev, the stable revision
740 - * @param Article $article
741 - * @param ParserOutput $stableOutput, will fetch if not given
742 - * @param ParserOutput $currentOutput, will fetch if not given
743 - * @return bool
744 - * See if a flagged revision is synced with the current.
745 - * This function is pretty expensive...
746 - */
747 - public static function stableVersionIsSynced(
748 - FlaggedRevision $srev,
749 - Article $article,
750 - ParserOutput $stableOutput = null,
751 - ParserOutput $currentOutput = null
 739+ * Check if all includes in $stableOutput are the same as those in $currentOutput
 740+ * @param ParserOutput $stableOutput
 741+ * @param ParserOutput $currentOutput
 742+ * @return bool
 743+ */
 744+ public static function includesAreSynced(
 745+ ParserOutput $stableOutput, ParserOutput $currentOutput
752746 ) {
753 - global $wgMemc, $wgEnableParserCache, $wgUser;
754 - # Stable text revision must be the same as the current
755 - if ( $srev->getRevId() < $article->getTitle()->getLatestRevID() ) {
756 - return false;
757 - }
758 - # Stable file revision must be the same as the current
759 - if ( $article instanceof ImagePage && $article->getFile() ) {
760 - if ( $srev->getFileTimestamp() < $article->getFile()->getTimestamp() ) {
761 - return false;
 747+ $sTmpls = $stableOutput->mTemplateIds;
 748+ $cTmpls = $currentOutput->mTemplateIds;
 749+ foreach ( $sTmpls as $name => $revId ) {
 750+ if ( isset( $cTmpls[$name] ) && $cTmpls[$name] != $revId ) {
 751+ return false; // updated/created
762752 }
763753 }
764 - # If using the current version of includes, there is nothing else to check.
765 - if ( self::inclusionSetting() == FR_INCLUDES_CURRENT ) {
766 - return true;
767 - }
768 - # Try the cache...
769 - $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() );
770 - $value = self::getMemcValue( $wgMemc->get( $key ), $article );
771 - if ( $value === "true" ) {
772 - return true;
773 - } elseif ( $value === "false" ) {
774 - return false;
775 - }
776 - # If parseroutputs not given, fetch them...
777 - if ( is_null( $stableOutput ) || !isset( $stableOutput->fr_newestTemplateID ) ) {
778 - # Get parsed stable version
779 - $anon = new User(); // anon cache most likely to exist
780 - $stableOutput = self::getPageCache( $article, $anon );
781 - if ( $stableOutput == false && $wgUser->getId() )
782 - $stableOutput = self::getPageCache( $article, $wgUser );
783 - # Regenerate the parser output as needed...
784 - if ( $stableOutput == false ) {
785 - $text = $srev->getRevText();
786 - $stableOutput = self::parseStableText( $article, $text, $srev->getRevId() );
787 - # Update the stable version cache
788 - self::updatePageCache( $article, $anon, $stableOutput );
789 - }
790 - }
791 - if ( is_null( $currentOutput ) || !isset( $currentOutput->fr_newestTemplateID ) ) {
792 - # Get parsed current version
793 - $parserCache = ParserCache::singleton();
794 - $currentOutput = false;
795 - $anon = new User(); // anon cache most likely to exist
796 - # If $text is set, then the stableOutput is new. In that case,
797 - # the current must also be new to avoid sync goofs.
798 - if ( !isset( $text ) ) {
799 - $currentOutput = $parserCache->get( $article, $anon );
800 - if ( $currentOutput == false && $wgUser->getId() )
801 - $currentOutput = $parserCache->get( $article, $wgUser );
 754+ $sFiles = $stableOutput->fr_ImageSHA1Keys;
 755+ $cFiles = $currentOutput->fr_ImageSHA1Keys;
 756+ foreach ( $sFiles as $name => $timeKey ) {
 757+ foreach ( $timeKey as $sTs => $sSha1 ) {
 758+ if ( isset( $cFiles[$name] ) && !isset( $cFiles[$name][$sTs] ) ) {
 759+ return false; // updated/created
 760+ }
802761 }
803 - # Regenerate the parser output as needed...
804 - if ( $currentOutput == false ) {
805 - global $wgParser;
806 - $rev = Revision::newFromTitle( $article->getTitle() );
807 - $text = $rev ? $rev->getText() : false;
808 - $id = $rev ? $rev->getId() : null;
809 - $title = $article->getTitle();
810 - $options = self::makeParserOptions( $anon );
811 - $currentOutput = $wgParser->parse( $text, $title, $options,
812 - /*$lineStart*/true, /*$clearState*/true, $id );
813 - # Might as well save the cache while we're at it
814 - if ( $wgEnableParserCache )
815 - $parserCache->save( $currentOutput, $article, $anon );
816 - }
817762 }
818 - # Only current of revisions of inclusions can be reviewed. Since the stable and current revisions
819 - # have the same text, the only thing that can make them different is updating a template or image.
820 - # If this is the case, the current revision will have a newer template or image version used somewhere.
821 - if ( $currentOutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) {
822 - $synced = false;
823 - } elseif ( $currentOutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) {
824 - $synced = false;
825 - } else {
826 - $synced = true;
827 - }
828 - # Save to cache. This will be updated whenever the page is re-parsed as well. This means
829 - # that MW can check a light-weight key first.
830 - global $wgParserCacheExpireTime;
831 - $data = self::makeMemcObj( $synced ? "true" : "false" );
832 - $wgMemc->set( $key, $data, $wgParserCacheExpireTime );
833 -
834 - return $synced;
 763+ return true;
835764 }
836765
837766 /**
@@ -1588,6 +1517,8 @@
15891518 $editInfo = $article->prepareTextForEdit( $text ); // Parse the revision HTML output
15901519 $poutput = $editInfo->output;
15911520
 1521+ $dbw = wfGetDB( DB_MASTER );
 1522+
15921523 # NS:title -> rev ID mapping
15931524 foreach ( $poutput->mTemplateIds as $namespace => $titleAndID ) {
15941525 foreach ( $titleAndID as $dbkey => $id ) {
@@ -1602,12 +1533,15 @@
16031534 # Image -> timestamp mapping
16041535 foreach ( $poutput->fr_ImageSHA1Keys as $dbkey => $timeAndSHA1 ) {
16051536 foreach ( $timeAndSHA1 as $time => $sha1 ) {
1606 - $imgset[] = array(
 1537+ $fileIncludeData = array(
16071538 'fi_rev_id' => $rev->getId(),
16081539 'fi_name' => $dbkey,
1609 - 'fi_img_timestamp' => $time,
16101540 'fi_img_sha1' => $sha1
16111541 );
 1542+ if ( $time ) { // b/c for bad <char(14) NOT NULL default ''> def
 1543+ $fileIncludeData['fi_img_timestamp'] = $dbw->timestamp( $time );
 1544+ }
 1545+ $imgset[] = $fileIncludeData;
16121546 }
16131547 }
16141548
Index: trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php
@@ -323,7 +323,8 @@
324324 private function approveRevision( $rev ) {
325325 global $wgUser, $wgMemc, $wgParser, $wgEnableParserCache;
326326 wfProfileIn( __METHOD__ );
327 -
 327+
 328+ $dbw = wfGetDB( DB_MASTER );
328329 $article = new Article( $this->page );
329330
330331 $quality = 0;
@@ -386,12 +387,16 @@
387388 if ( $timestamp > $lastImgTime )
388389 $lastImgTime = $timestamp;
389390
390 - $imgset[] = array(
391 - 'fi_rev_id' => $rev->getId(),
392 - 'fi_name' => $img_title->getDBkey(),
393 - 'fi_img_timestamp' => $timestamp,
394 - 'fi_img_sha1' => $key
 391+ $fileIncludeData = array(
 392+ 'fi_rev_id' => $rev->getId(),
 393+ 'fi_name' => $img_title->getDBkey(),
 394+ 'fi_img_sha1' => $key
395395 );
 396+ if ( $time ) { // b/c for bad <char(14) NOT NULL default ''> def
 397+ $fileIncludeData['fi_img_timestamp'] = $dbw->timestamp( $timestamp );
 398+ }
 399+ $imgset[] = $fileIncludeData;
 400+
396401 if ( !isset( $imgParams[$img_title->getDBkey()] ) ) {
397402 $imgParams[$img_title->getDBkey()] = array();
398403 }
@@ -445,19 +450,14 @@
446451
447452 # Is this a duplicate review?
448453 if ( $oldfrev && $flaggedOutput ) {
449 - $synced = true;
450 - if ( $stableOutput->fr_newestImageTime != $flaggedOutput->fr_newestImageTime )
451 - $synced = false;
452 - elseif ( $stableOutput->fr_newestTemplateID != $flaggedOutput->fr_newestTemplateID )
453 - $synced = false;
454 - elseif ( $oldfrev->getTags() != $flags )
455 - $synced = false;
456 - elseif ( $oldfrev->getFileSha1() != @$fileData['sha1'] )
457 - $synced = false;
458 - elseif ( $oldfrev->getComment() != $this->notes )
459 - $synced = false;
460 - elseif ( $oldfrev->getQuality() != $quality )
461 - $synced = false;
 454+ $fileSha1 = $fileData ?
 455+ $fileData['sha1'] : null; // stable upload version for file pages
 456+ $synced = (
 457+ $oldfrev->getTags() == $flags && // tags => quality
 458+ $oldfrev->getFileSha1() == $fileSha1 &&
 459+ $oldfrev->getComment() == $this->notes &&
 460+ FlaggedRevs::includesAreSynced( $stableOutput, $flaggedOutput )
 461+ );
462462 # Don't review if the same
463463 if ( $synced ) {
464464 wfProfileOut( __METHOD__ );
@@ -465,7 +465,6 @@
466466 }
467467 }
468468
469 - $dbw = wfGetDB( DB_MASTER );
470469 # Our review entry
471470 $flaggedRevision = new FlaggedRevision( array(
472471 'fr_rev_id' => $rev->getId(),
@@ -498,8 +497,10 @@
499498 || !isset( $poutput->fr_newestTemplateID )
500499 || !isset( $poutput->fr_newestImageTime ) )
501500 {
 501+ $source = $article->getContent();
502502 $options = FlaggedRevs::makeParserOptions();
503 - $poutput = $wgParser->parse( $article->getContent(), $article->mTitle, $options );
 503+ $poutput = $wgParser->parse( $source, $article->getTitle(), $options,
 504+ /*$lineStart*/true, /*$clearState*/true, $article->getLatest() );
504505 }
505506 # Prepare for a link tracking update
506507 $u = new LinksUpdate( $this->page, $poutput );
@@ -659,7 +660,7 @@
660661 * @return mixed (string/false)
661662 */
662663 public static function buildQuickReview(
663 - $article, $rev, $templateIDs, $imageSHA1Keys, $stableDiff = false
 664+ FlaggedArticle $article, $rev, $templateIDs, $imageSHA1Keys, $stableDiff = false
664665 ) {
665666 global $wgUser, $wgRequest;
666667 # The revision must be valid and public
@@ -688,8 +689,7 @@
689690 }
690691 $reviewNotes = $srev->getComment();
691692 # Re-review button is need for template/file only review case
692 - $allowRereview = ( $srev->getRevId() == $id )
693 - && !FlaggedRevs::stableVersionIsSynced( $srev, $article );
 693+ $allowRereview = ( $srev->getRevId() == $id && !$article->stableVersionIsSynced() );
694694 } else {
695695 $flags = $oldFlags;
696696 // Get existing notes to pre-fill field
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -397,7 +397,7 @@
398398 }
399399 return true;
400400 }
401 -
 401+
402402 protected static function addLink( array &$links, $ns, $dbKey ) {
403403 if ( !isset( $links[$ns] ) ) {
404404 $links[$ns] = array();
@@ -593,9 +593,10 @@
594594 array( 'fi_rev_id' => $parser->getRevisionId(), 'fi_name' => $title->getDBkey() ),
595595 __METHOD__
596596 );
 597+ $reviewedTS = trim( $row->fi_img_timestamp ); // remove garbage
597598 # Only the one picked at review time exists OR it is the newest...use it!
598 - if ( $row && ( $time === false || $row->fi_img_timestamp > $time ) ) {
599 - $time = $row->fi_img_timestamp;
 599+ if ( $row && ( $time === false || $reviewedTS > $time ) ) {
 600+ $time = $reviewedTS;
600601 $sha1 = $row->fi_img_sha1;
601602 $isKnownLocal = false; // up in the air...possibly a commons image
602603 }
@@ -685,9 +686,10 @@
686687 array( 'fi_rev_id' => $ig->mRevisionId, 'fi_name' => $nt->getDBkey() ),
687688 __METHOD__
688689 );
 690+ $reviewedTS = trim( $row->fi_img_timestamp ); // remove garbage
689691 # Only the one picked at review time exists OR it is the newest...use it!
690 - if ( $row && ( $time === false || $row->fi_img_timestamp > $time ) ) {
691 - $time = $row->fi_img_timestamp;
 692+ if ( $row && ( $time === false || $reviewedTS > $time ) ) {
 693+ $time = $reviewedTS;
692694 $sha1 = $row->fi_img_sha1;
693695 $isKnownLocal = false; // up in the air...possibly a commons image
694696 }
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -36,7 +36,7 @@
3737 $this->loaded = true;
3838 $this->article = self::globalArticleInstance();
3939 if ( $this->article == null ) {
40 - throw new MWException( 'FlaggedArticleViewer has no context article!' );
 40+ throw new MWException( 'FlaggedArticleView has no context article!' );
4141 }
4242 }
4343 }
@@ -354,7 +354,7 @@
355355 $quality = FlaggedRevs::isQuality( $flags );
356356 $pristine = FlaggedRevs::isPristine( $flags );
357357 # Get stable version sync status
358 - $synced = FlaggedRevs::stableVersionIsSynced( $srev, $this->article );
 358+ $synced = $this->article->stableVersionIsSynced();
359359 if ( $synced ) {
360360 $this->setReviewNotes( $srev ); // Still the same
361361 } else {
@@ -549,7 +549,7 @@
550550 $parserOut = null;
551551 }
552552 }
553 - $synced = FlaggedRevs::stableVersionIsSynced( $srev, $this->article, $parserOut, null );
 553+ $synced = $this->article->stableVersionIsSynced( $parserOut, null );
554554 # Construct some tagging
555555 if ( !$wgOut->isPrintable() && !( $this->article->lowProfileUI() && $synced ) ) {
556556 $revsSince = $this->article->getPendingRevCount();
@@ -1093,7 +1093,7 @@
10941094 if ( !$srev ) {
10951095 return true; // No stable revision exists
10961096 }
1097 - $synced = FlaggedRevs::stableVersionIsSynced( $srev, $fa );
 1097+ $synced = $this->article->stableVersionIsSynced();
10981098 $pendingEdits = !$synced && $fa->isStableShownByDefault();
10991099 // Set the edit tab names as needed...
11001100 if ( $pendingEdits ) {
@@ -1134,7 +1134,8 @@
11351135 $tabs['read']['class'] = 'selected';
11361136 } elseif ( self::isViewAction( $action ) ) {
11371137 // Are we looking at a draft/current revision?
1138 - if ( $wgOut->getRevisionId() > $srev->getRevId() ) {
 1138+ // Note: there may *just* be template/file changes.
 1139+ if ( $wgOut->getRevisionId() >= $srev->getRevId() ) {
11391140 $tabs['draft']['class'] = 'selected';
11401141 // Otherwise, fallback to regular tab behavior
11411142 } else {
@@ -1294,11 +1295,14 @@
12951296 * Add a link to diff-to-stable for reviewable pages
12961297 */
12971298 protected function diffToStableLink( FlaggedRevision $frev, Revision $newRev ) {
1298 - global $wgUser, $wgOut;
 1299+ global $wgUser;
12991300 $this->load();
13001301 $review = '';
1301 - # Make a link to the full diff-to-stable as needed
1302 - if ( !$this->isDiffFromStable || !$newRev->isCurrent() ) {
 1302+ # Make a link to the full diff-to-stable if:
 1303+ # (a) Actual revs are pending and (b) We are not viewing the stable diff
 1304+ if ( $this->article->revsArePending() &&
 1305+ !( $this->isDiffFromStable && $newRev->isCurrent() ) )
 1306+ {
13031307 $review = $wgUser->getSkin()->makeKnownLinkObj(
13041308 $this->article->getTitle(),
13051309 wfMsgHtml( 'review-diff2stable' ),
@@ -1310,7 +1314,9 @@
13111315 return $review;
13121316 }
13131317
1314 - // add [checked version] and such to left and right side of diff
 1318+ /**
 1319+ * Add [checked version] and such to left and right side of diff
 1320+ */
13151321 protected function diffReviewMarkers( $oldRev, $newRev ) {
13161322 $form = '';
13171323 $oldRevQ = $newRevQ = false;
@@ -1374,41 +1380,44 @@
13751381 global $wgUser;
13761382 $skin = $wgUser->getSkin();
13771383 $dbr = wfGetDB( DB_SLAVE );
1378 - // Get templates where the current and stable are not the same revision
 1384+ # Get templates where the current and stable are not the same revision
13791385 $ret = $dbr->select( array( 'flaggedtemplates', 'page', 'flaggedpages' ),
1380 - array( 'ft_namespace', 'ft_title', 'fp_stable',
1381 - 'ft_tmp_rev_id', 'page_latest' ),
1382 - array( 'ft_rev_id' => $frev->getRevId(),
1383 - 'page_namespace = ft_namespace',
1384 - 'page_title = ft_title' ),
 1386+ array( 'ft_namespace', 'ft_title', 'fp_stable', 'ft_tmp_rev_id', 'page_latest' ),
 1387+ array( 'ft_rev_id' => $frev->getRevId() ),
13851388 __METHOD__,
13861389 array(), /* OPTIONS */
1387 - array( 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ) )
 1390+ array(
 1391+ 'page' => array( 'LEFT JOIN',
 1392+ 'page_namespace = ft_namespace AND page_title = ft_title' ),
 1393+ 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ) )
13881394 );
13891395 $tmpChanges = array();
13901396 while ( $row = $dbr->fetchObject( $ret ) ) {
13911397 $title = Title::makeTitleSafe( $row->ft_namespace, $row->ft_title );
1392 - $revIdDraft = $row->page_latest;
1393 - // stable time -> time when reviewed (unless the other is newer)
1394 - $revIdStable = isset( $row->fp_stable ) && $row->fp_stable >= $row->ft_tmp_rev_id ?
1395 - $row->fp_stable : $row->ft_tmp_rev_id;
1396 - // compare to current
1397 - if ( $revIdDraft > $revIdStable ) {
1398 - $tmpChanges[] = $skin->makeKnownLinkObj( $title,
 1398+ $revIdDraft = $row->page_latest; // may be NULL
 1399+ # Stable time -> time when reviewed (unless the other is newer)
 1400+ $revIdStable = $row->fp_stable && $row->fp_stable >= $row->ft_tmp_rev_id
 1401+ ? $row->fp_stable
 1402+ : $row->ft_tmp_rev_id;
 1403+ # Compare to current...
 1404+ $deleted = ( !$revIdDraft && $revIdStable ); // later deleted
 1405+ $updated = ( $revIdDraft && $revIdDraft > $revIdStable ); // updated/created
 1406+ if ( $deleted || $updated ) {
 1407+ $tmpChanges[] = $skin->makeLinkObj( $title,
13991408 $title->getPrefixedText(),
1400 - 'diff=cur&oldid=' . intval( $revIdStable ) );
 1409+ 'diff=cur&oldid=' . (int)$revIdStable );
14011410 }
14021411 }
14031412 return $tmpChanges;
14041413 }
1405 -
 1414+
14061415 // Fetch file changes for a reviewed revision since review
14071416 // @returns array
14081417 protected function fetchFileChanges( FlaggedRevision $frev ) {
14091418 global $wgUser;
14101419 $skin = $wgUser->getSkin();
14111420 $dbr = wfGetDB( DB_SLAVE );
1412 - // Get images where the current and stable are not the same revision
 1421+ # Get images where the current and stable are not the same revision
14131422 $ret = $dbr->select(
14141423 array( 'flaggedimages', 'page', 'image', 'flaggedpages', 'flaggedrevs' ),
14151424 array( 'fi_name', 'fi_img_timestamp', 'fr_img_timestamp' ),
@@ -1426,13 +1435,18 @@
14271436 $imgChanges = array();
14281437 while ( $row = $dbr->fetchObject( $ret ) ) {
14291438 $title = Title::makeTitleSafe( NS_FILE, $row->fi_name );
1430 - // stable time -> time when reviewed (unless the other is newer)
1431 - $timestamp = isset( $row->fr_img_timestamp ) && $row->fr_img_timestamp >= $row->fi_img_timestamp ?
1432 - $row->fr_img_timestamp : $row->fi_img_timestamp;
1433 - // compare to current
 1439+ $reviewedTS = trim( $row->fi_img_timestamp ); // may be ''/NULL
 1440+ # Stable time -> time when reviewed (unless the other is newer)
 1441+ $tsStable = $row->fr_img_timestamp && $row->fr_img_timestamp >= $reviewedTS
 1442+ ? $row->fr_img_timestamp
 1443+ : $reviewedTS;
 1444+ # Compare to current...
14341445 $file = wfFindFile( $title );
1435 - if ( $file && $file->getTimestamp() > $timestamp ) {
1436 - $imgChanges[] = $skin->makeKnownLinkObj( $title, $title->getPrefixedText() );
 1446+ $deleted = ( !$file && $tsStable ); // later deleted
 1447+ $updated = ( $file && $file->getTimestamp() > $tsStable ); // updated/created
 1448+ if ( $deleted || $updated ) {
 1449+ // @TODO: change when MW has file diffs
 1450+ $imgChanges[] = $skin->makeLinkObj( $title, $title->getPrefixedText() );
14371451 }
14381452 }
14391453 return $imgChanges;

Follow-up revisions

RevisionCommit summaryAuthorDate
r68057* Rewrote stableVersionIsSynced() to use findPendingTemplateChanges()/findPen...aaron03:53, 15 June 2010
r82917(bug 23415) Mark articles as needing review if a file version used in the sta...aaron22:01, 27 February 2011

Status & tagging log