Index: trunk/extensions/FlaggedRevs/maintenance/updateTracking.inc |
— | — | @@ -128,8 +128,7 @@ |
129 | 129 | $frev = FlaggedRevision::determineStable( $title, FR_MASTER ); |
130 | 130 | # Update fp_stable, fp_quality, and fp_reviewed |
131 | 131 | if( $frev ) { |
132 | | - FlaggedRevs::updateStableVersion( |
133 | | - $article, $frev->getRevision(), $row->page_latest ); |
| 132 | + FlaggedRevs::updateStableVersion( $article, $frev, $row->page_latest ); |
134 | 133 | # Somethings broke? Delete the row... |
135 | 134 | } else { |
136 | 135 | FlaggedRevs::clearTrackingRows( $row->page_id ); |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -10,6 +10,8 @@ |
11 | 11 | protected $revsArePending = null; |
12 | 12 | protected $pendingRevCount = null; |
13 | 13 | protected $pageConfig = null; |
| 14 | + protected $syncedInTracking = null; |
| 15 | + |
14 | 16 | protected $imagePage = null; // for file pages |
15 | 17 | |
16 | 18 | protected $stabilityDataLoaded = false; |
— | — | @@ -332,7 +334,8 @@ |
333 | 335 | $row = $db->selectRow( |
334 | 336 | array( 'page', 'flaggedpages', 'flaggedrevs', 'flaggedpage_config' ), |
335 | 337 | array_merge( FlaggedRevision::selectFields(), |
336 | | - FlaggedPageConfig::selectFields(), array( 'fp_pending_since' ) ), |
| 338 | + FlaggedPageConfig::selectFields(), |
| 339 | + array( 'fp_pending_since', 'fp_reviewed' ) ), |
337 | 340 | array( 'page_id' => $this->getID() ), |
338 | 341 | __METHOD__, |
339 | 342 | array(), |
— | — | @@ -355,5 +358,16 @@ |
356 | 359 | } |
357 | 360 | } |
358 | 361 | $this->revsArePending = ( $row->fp_pending_since !== null ); // revs await review |
| 362 | + $this->syncedInTracking = (bool)$row->fp_reviewed; |
359 | 363 | } |
| 364 | + |
| 365 | + /* |
| 366 | + * Get the fp_reviewed value for this page |
| 367 | + * @param int $flags FR_MASTER |
| 368 | + * @return bool |
| 369 | + */ |
| 370 | + public function syncedInTracking( $flags = 0 ) { |
| 371 | + $this->loadFlaggedRevsData( $flags ); |
| 372 | + return $this->syncedInTracking; |
| 373 | + } |
360 | 374 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -645,6 +645,22 @@ |
646 | 646 | wfProfileOut( __METHOD__ ); |
647 | 647 | } |
648 | 648 | |
| 649 | + /** |
| 650 | + * @param Article $article |
| 651 | + * @param bool $synced |
| 652 | + * Updates the fp_reviewed field for this article |
| 653 | + */ |
| 654 | + public static function updateSyncStatus( Article $article, $synced ) { |
| 655 | + wfProfileIn( __METHOD__ ); |
| 656 | + $dbw = wfGetDB( DB_MASTER ); |
| 657 | + $dbw->update( 'flaggedpages', |
| 658 | + array( 'fp_reviewed' => (int)$synced ), |
| 659 | + array( 'fp_page_id' => $article->getID() ), |
| 660 | + __METHOD__ |
| 661 | + ); |
| 662 | + wfProfileOut( __METHOD__ ); |
| 663 | + } |
| 664 | + |
649 | 665 | # ################ Tracking/cache update update functions ################# |
650 | 666 | |
651 | 667 | /** |
— | — | @@ -672,7 +688,7 @@ |
673 | 689 | } else { |
674 | 690 | $article = new Article( $title ); |
675 | 691 | # Update flagged page related fields |
676 | | - FlaggedRevs::updateStableVersion( $article, $sv->getRevision() ); |
| 692 | + FlaggedRevs::updateStableVersion( $article, $sv ); |
677 | 693 | # Lazily rebuild dependancies on next parse (we invalidate below) |
678 | 694 | FlaggedRevs::clearStableOnlyDeps( $title ); |
679 | 695 | # Check if pages using this need to be invalidated/purged... |
— | — | @@ -702,14 +718,15 @@ |
703 | 719 | |
704 | 720 | /** |
705 | 721 | * @param Article $article |
706 | | - * @param Revision $rev, the new stable version |
| 722 | + * @param FlaggedRevision $srev, the new stable version |
707 | 723 | * @param mixed $latest, the latest rev ID (optional) |
708 | 724 | * Updates the tracking tables and pending edit count cache. Called on edit. |
709 | 725 | */ |
710 | 726 | public static function updateStableVersion( |
711 | | - Article $article, Revision $rev, $latest = null |
| 727 | + Article $article, FlaggedRevision $srev, $latest = null |
712 | 728 | ) { |
713 | | - if ( !$article->getId() ) { |
| 729 | + $rev = $srev->getRevision(); |
| 730 | + if ( !$rev || !$article->getId() ) { |
714 | 731 | return true; // no bogus entries |
715 | 732 | } |
716 | 733 | # Get the latest revision ID if not set |
— | — | @@ -744,13 +761,19 @@ |
745 | 762 | $nextTimestamp = $nextEditTS; |
746 | 763 | } |
747 | 764 | } |
| 765 | + # Get the new page sync status... |
| 766 | + $synced = !( |
| 767 | + $nextTimestamp !== null || // edits pending |
| 768 | + $srev->findPendingTemplateChanges() || // template changes pending |
| 769 | + $srev->findPendingFileChanges( 'noForeign' ) // file changes pending |
| 770 | + ); |
748 | 771 | # Alter table metadata |
749 | 772 | $dbw->replace( 'flaggedpages', |
750 | 773 | array( 'fp_page_id' ), |
751 | 774 | array( |
752 | 775 | 'fp_page_id' => $article->getId(), |
753 | 776 | 'fp_stable' => $rev->getId(), |
754 | | - 'fp_reviewed' => ( $nextTimestamp === null ) ? 1 : 0, |
| 777 | + 'fp_reviewed' => $synced ? 1 : 0, |
755 | 778 | 'fp_quality' => ( $maxQuality === false ) ? null : $maxQuality, |
756 | 779 | 'fp_pending_since' => $dbw->timestampOrNull( $nextTimestamp ) |
757 | 780 | ), |
Index: trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php |
— | — | @@ -327,7 +327,7 @@ |
328 | 328 | # Refresh tracking to account for any hidden reviewed versions... |
329 | 329 | $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER ); |
330 | 330 | if ( $frev ) { |
331 | | - FlaggedRevs::updateStableVersion( $article, $frev->getRevision(), $latest ); |
| 331 | + FlaggedRevs::updateStableVersion( $article, $frev, $latest ); |
332 | 332 | } else { |
333 | 333 | FlaggedRevs::clearTrackingRows( $article->getId() ); |
334 | 334 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -693,15 +693,25 @@ |
694 | 694 | $parserOptions = FlaggedRevs::makeParserOptions(); |
695 | 695 | $parserOut = FlaggedRevs::parseStableText( |
696 | 696 | $this->article->getTitle(), $text, $srev->getRevId(), $parserOptions ); |
697 | | - # Update the stable version cache & dependancies |
| 697 | + # Update the stable version cache |
698 | 698 | FlaggedRevs::updatePageCache( $this->article, $parserOptions, $parserOut ); |
| 699 | + # Add the stable output to the page view |
| 700 | + $this->addParserOutput( $parserOut ); |
| 701 | + |
| 702 | + # Update the stable version dependancies |
699 | 703 | FlaggedRevs::updateCacheTracking( $this->article, $parserOut ); |
700 | | - |
701 | | - $this->addParserOutput( $parserOut ); |
702 | 704 | } else { |
703 | 705 | $wgOut->addHtml( $redirHtml ); |
704 | 706 | } |
705 | 707 | } |
| 708 | + |
| 709 | + # Update page sync status for tracking purposes. |
| 710 | + # NOTE: avoids master hits and doesn't have to be perfect for what it does |
| 711 | + if ( !$this->article->revsArePending() // already updated on edit |
| 712 | + && $this->article->syncedInTracking() != $synced ) |
| 713 | + { |
| 714 | + FlaggedRevs::updateSyncStatus( $this->article, $synced ); |
| 715 | + } |
706 | 716 | } |
707 | 717 | |
708 | 718 | // Add parser output and update title |