r84097 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84096‎ | r84097 | r84098 >
Date:12:39, 16 March 2011
Author:aaron
Status:resolved
Tags:
Comment:
* fp_reviewed is not currently used (redundant to fp_pending_since). Re-purposed it to handling total sync status (not just whether edits are pending).
* defer tracking updates till after addParserOutput()
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/forms/PageStabilityForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/updateTracking.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/updateTracking.inc
@@ -128,8 +128,7 @@
129129 $frev = FlaggedRevision::determineStable( $title, FR_MASTER );
130130 # Update fp_stable, fp_quality, and fp_reviewed
131131 if( $frev ) {
132 - FlaggedRevs::updateStableVersion(
133 - $article, $frev->getRevision(), $row->page_latest );
 132+ FlaggedRevs::updateStableVersion( $article, $frev, $row->page_latest );
134133 # Somethings broke? Delete the row...
135134 } else {
136135 FlaggedRevs::clearTrackingRows( $row->page_id );
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -10,6 +10,8 @@
1111 protected $revsArePending = null;
1212 protected $pendingRevCount = null;
1313 protected $pageConfig = null;
 14+ protected $syncedInTracking = null;
 15+
1416 protected $imagePage = null; // for file pages
1517
1618 protected $stabilityDataLoaded = false;
@@ -332,7 +334,8 @@
333335 $row = $db->selectRow(
334336 array( 'page', 'flaggedpages', 'flaggedrevs', 'flaggedpage_config' ),
335337 array_merge( FlaggedRevision::selectFields(),
336 - FlaggedPageConfig::selectFields(), array( 'fp_pending_since' ) ),
 338+ FlaggedPageConfig::selectFields(),
 339+ array( 'fp_pending_since', 'fp_reviewed' ) ),
337340 array( 'page_id' => $this->getID() ),
338341 __METHOD__,
339342 array(),
@@ -355,5 +358,16 @@
356359 }
357360 }
358361 $this->revsArePending = ( $row->fp_pending_since !== null ); // revs await review
 362+ $this->syncedInTracking = (bool)$row->fp_reviewed;
359363 }
 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+ }
360374 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -645,6 +645,22 @@
646646 wfProfileOut( __METHOD__ );
647647 }
648648
 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+
649665 # ################ Tracking/cache update update functions #################
650666
651667 /**
@@ -672,7 +688,7 @@
673689 } else {
674690 $article = new Article( $title );
675691 # Update flagged page related fields
676 - FlaggedRevs::updateStableVersion( $article, $sv->getRevision() );
 692+ FlaggedRevs::updateStableVersion( $article, $sv );
677693 # Lazily rebuild dependancies on next parse (we invalidate below)
678694 FlaggedRevs::clearStableOnlyDeps( $title );
679695 # Check if pages using this need to be invalidated/purged...
@@ -702,14 +718,15 @@
703719
704720 /**
705721 * @param Article $article
706 - * @param Revision $rev, the new stable version
 722+ * @param FlaggedRevision $srev, the new stable version
707723 * @param mixed $latest, the latest rev ID (optional)
708724 * Updates the tracking tables and pending edit count cache. Called on edit.
709725 */
710726 public static function updateStableVersion(
711 - Article $article, Revision $rev, $latest = null
 727+ Article $article, FlaggedRevision $srev, $latest = null
712728 ) {
713 - if ( !$article->getId() ) {
 729+ $rev = $srev->getRevision();
 730+ if ( !$rev || !$article->getId() ) {
714731 return true; // no bogus entries
715732 }
716733 # Get the latest revision ID if not set
@@ -744,13 +761,19 @@
745762 $nextTimestamp = $nextEditTS;
746763 }
747764 }
 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+ );
748771 # Alter table metadata
749772 $dbw->replace( 'flaggedpages',
750773 array( 'fp_page_id' ),
751774 array(
752775 'fp_page_id' => $article->getId(),
753776 'fp_stable' => $rev->getId(),
754 - 'fp_reviewed' => ( $nextTimestamp === null ) ? 1 : 0,
 777+ 'fp_reviewed' => $synced ? 1 : 0,
755778 'fp_quality' => ( $maxQuality === false ) ? null : $maxQuality,
756779 'fp_pending_since' => $dbw->timestampOrNull( $nextTimestamp )
757780 ),
Index: trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php
@@ -327,7 +327,7 @@
328328 # Refresh tracking to account for any hidden reviewed versions...
329329 $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER );
330330 if ( $frev ) {
331 - FlaggedRevs::updateStableVersion( $article, $frev->getRevision(), $latest );
 331+ FlaggedRevs::updateStableVersion( $article, $frev, $latest );
332332 } else {
333333 FlaggedRevs::clearTrackingRows( $article->getId() );
334334 }
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -693,15 +693,25 @@
694694 $parserOptions = FlaggedRevs::makeParserOptions();
695695 $parserOut = FlaggedRevs::parseStableText(
696696 $this->article->getTitle(), $text, $srev->getRevId(), $parserOptions );
697 - # Update the stable version cache & dependancies
 697+ # Update the stable version cache
698698 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
699703 FlaggedRevs::updateCacheTracking( $this->article, $parserOut );
700 -
701 - $this->addParserOutput( $parserOut );
702704 } else {
703705 $wgOut->addHtml( $redirHtml );
704706 }
705707 }
 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+ }
706716 }
707717
708718 // Add parser output and update title

Follow-up revisions

RevisionCommit summaryAuthorDate
r84171Simplify code from r84097 a bit and handle severe slave lagaaron15:31, 17 March 2011
r84178* Follow-up r84097: check wfReadOnly(); didn't find anything else needing these...aaron16:41, 17 March 2011

Status & tagging log