r85955 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85954‎ | r85955 | r85956 >
Date:16:16, 13 April 2011
Author:aaron
Status:ok
Tags:
Comment:
* In FlaggedRevision:
** Fetch revision with other fields at once in in FlaggedRevision
** Added short-circuit to newFromTitle (revid=0)
** Param doc tweaks
* In FlaggedArticle:
** Made load function fetch page, flaggedpages, and flaggedpage_config fields at once (uses r85913)
** Defer loading the FlaggedRevision object though
** Removed $flags clutter in functions; added loadFromDB() to use instead
** Moved updateStableVersion() and friends here, were they belong
** Optimized $maxQuality check in updateStableVersion()
* In FlaggedRevs:
** Added highestReviewTier() function
** Moved functions mentioned above
* In PageStabilityForm:
** Try to avoid excess stableVersionUpdates() calls
* In updateTracking.inc:
** Dependency tracking and cache fixes
** Code style cleanups
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/business/PageStabilityForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/updateTracking.inc (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedArticleView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/updateTracking.inc
@@ -7,11 +7,11 @@
88
99 $db = wfGetDB( DB_MASTER );
1010
11 - if( $start === null ) {
 11+ if ( $start === null ) {
1212 $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ );
1313 }
1414 $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ );
15 - if( is_null( $start ) || is_null( $end ) ) {
 15+ if ( is_null( $start ) || is_null( $end ) ) {
1616 echo "...revision table seems to be empty.\n";
1717 return;
1818 }
@@ -21,7 +21,7 @@
2222 $blockEnd = $start + $BATCH_SIZE - 1;
2323 $count = 0;
2424 $changed = 0;
25 - while( $blockEnd <= $end ) {
 25+ while ( $blockEnd <= $end ) {
2626 echo "...doing fr_rev_id from $blockStart to $blockEnd\n";
2727 $cond = "rev_id BETWEEN $blockStart AND $blockEnd
2828 AND fr_page_id = rev_page AND fr_rev_id = rev_id AND page_id = rev_page";
@@ -32,17 +32,17 @@
3333 );
3434 $db->begin();
3535 # Go through and clean up missing items, as well as correct fr_quality...
36 - foreach( $res as $row ) {
 36+ foreach ( $res as $row ) {
3737 $tags = FlaggedRevision::expandRevisionTags( $row->fr_tags );
3838 # Quality rating levels may have changed due to config tweaks...
39 - if( FlaggedRevs::isPristine( $tags ) ) {
 39+ if ( FlaggedRevs::isPristine( $tags ) ) {
4040 $quality = 2;
4141 } else {
4242 $quality = FlaggedRevs::isQuality( $tags ) ? 1 : 0;
4343 }
4444 $time = $sha1 = $file = null;
4545 # Check for file version to see if it's stored the old way...
46 - if( !$row->fr_img_name && $row->page_namespace == NS_IMAGE ) {
 46+ if ( !$row->fr_img_name && $row->page_namespace == NS_IMAGE ) {
4747 $irow = $db->selectRow( 'flaggedimages',
4848 array( 'fi_img_timestamp', 'fi_img_sha1' ),
4949 array( 'fi_rev_id' => $row->fr_rev_id,
@@ -52,7 +52,7 @@
5353 $sha1 = $irow ? $irow->fi_img_sha1 : null;
5454 $file = $irow ? $row->page_title : null;
5555 # Fill in from current if broken
56 - if( !$irow ) {
 56+ if ( !$irow ) {
5757 $crow = $db->selectRow( 'image',
5858 array( 'img_timestamp', 'img_sha1' ),
5959 array( 'img_name' => $row->page_title ),
@@ -62,12 +62,12 @@
6363 $file = $crow ? $row->page_title : null;
6464 }
6565 # Leave it alone if already set
66 - } elseif( $row->fr_img_name && $row->page_namespace == NS_IMAGE ) {
 66+ } elseif ( $row->fr_img_name && $row->page_namespace == NS_IMAGE ) {
6767 $time = $row->fr_img_timestamp;
6868 $sha1 = $row->fr_img_sha1;
6969 $file = $row->fr_img_name;
7070 }
71 - if( $quality != $row->fr_quality
 71+ if ( $quality != $row->fr_quality
7272 || $file != $row->fr_img_name
7373 || $sha1 != $row->fr_img_sha1
7474 || $time != $row->fr_img_timestamp )
@@ -101,11 +101,11 @@
102102
103103 $db = wfGetDB( DB_MASTER );
104104
105 - if( $start === null ) {
 105+ if ( $start === null ) {
106106 $start = $db->selectField( 'page', 'MIN(page_id)', false, __FUNCTION__ );
107107 }
108108 $end = $db->selectField( 'page', 'MAX(page_id)', false, __FUNCTION__ );
109 - if( is_null( $start ) || is_null( $end ) ) {
 109+ if ( is_null( $start ) || is_null( $end ) ) {
110110 echo "...flaggedpages table seems to be empty.\n";
111111 return;
112112 }
@@ -114,37 +114,44 @@
115115 $blockStart = $start;
116116 $blockEnd = $start + $BATCH_SIZE - 1;
117117 $count = $deleted = $fixed = 0;
118 - while( $blockEnd <= $end ) {
 118+ while ( $blockEnd <= $end ) {
119119 echo "...doing page_id from $blockStart to $blockEnd\n";
120120 $cond = "page_id BETWEEN $blockStart AND $blockEnd";
121121 $res = $db->select( 'page', array('page_id','page_namespace','page_title','page_latest'),
122122 $cond, __FUNCTION__ );
123123 # Go through and update the de-normalized references...
124124 $db->begin();
125 - foreach( $res as $row ) {
 125+ foreach ( $res as $row ) {
126126 $title = Title::newFromRow( $row );
127 - $article = new Article( $title );
128 - # Replaces new fields into flaggedpages
 127+ $article = new FlaggedArticle( $title );
 128+ $oldFrev = FlaggedRevision::newFromStable( $title, FR_MASTER );
129129 $frev = FlaggedRevision::determineStable( $title, FR_MASTER );
130130 # Update fp_stable, fp_quality, and fp_reviewed
131 - if( $frev ) {
132 - FlaggedRevs::updateStableVersion( $article, $frev, $row->page_latest );
 131+ if ( $frev ) {
 132+ $article->updateStableVersion( $frev, $row->page_latest );
 133+ $changed = ( !$oldFrev || $oldFrev->getRevId() != $frev->getRevId() );
133134 # Somethings broke? Delete the row...
134135 } else {
135 - FlaggedRevs::clearTrackingRows( $row->page_id );
136 - if( $db->affectedRows() > 0 ) $deleted++;
 136+ $article->clearStableVersion();
 137+ if ( $db->affectedRows() > 0 ) $deleted++;
 138+ $changed = (bool)$oldFrev;
137139 }
138140 # Get the latest revision
139141 $revRow = $db->selectRow( 'revision', '*',
140142 array('rev_page' => $row->page_id), __FUNCTION__,
141143 array('ORDER BY' => 'rev_timestamp DESC') );
142144 # Correct page_latest if needed (import/files made plenty of bad rows)
143 - if( $revRow ) {
 145+ if ( $revRow ) {
144146 $revision = new Revision( $revRow );
145 - if( $article->updateIfNewerOn( $db, $revision ) ) {
 147+ if ( $article->updateIfNewerOn( $db, $revision ) ) {
146148 $fixed++;
147149 }
148150 }
 151+ if ( $changed ) {
 152+ # Lazily rebuild dependancies on next parse (we invalidate below)
 153+ FlaggedRevs::clearStableOnlyDeps( $title );
 154+ $title->invalidateCache();
 155+ }
149156 $count++;
150157 }
151158 $db->freeResult( $res );
@@ -172,11 +179,11 @@
173180
174181 $db = wfGetDB( DB_MASTER );
175182
176 - if( $start === null ) {
 183+ if ( $start === null ) {
177184 $start = $db->selectField( 'flaggedimages', 'MIN(fi_rev_id)', false, __FUNCTION__ );
178185 }
179186 $end = $db->selectField( 'flaggedimages', 'MAX(fi_rev_id)', false, __FUNCTION__ );
180 - if( is_null( $start ) || is_null( $end ) ) {
 187+ if ( is_null( $start ) || is_null( $end ) ) {
181188 echo "...flaggedimages table seems to be empty.\n";
182189 return;
183190 }
@@ -185,7 +192,7 @@
186193 $blockStart = $start;
187194 $blockEnd = $start + $BATCH_SIZE - 1;
188195 $nulled = 0;
189 - while( $blockEnd <= $end ) {
 196+ while ( $blockEnd <= $end ) {
190197 echo "...doing fi_rev_id from $blockStart to $blockEnd\n";
191198 $cond = "fi_rev_id BETWEEN $blockStart AND $blockEnd";
192199 $db->begin();
@@ -195,7 +202,7 @@
196203 array( $cond, "fi_img_timestamp = '' OR LOCATE( '\\0', fi_img_timestamp )" ),
197204 __FUNCTION__
198205 );
199 - if( $db->affectedRows() > 0 ) {
 206+ if ( $db->affectedRows() > 0 ) {
200207 $nulled += $db->affectedRows();
201208 }
202209 $db->commit();
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -6,6 +6,7 @@
77 */
88 class FlaggedArticle extends Article {
99 /* Process cache variables */
 10+ protected $stable = 0;
1011 protected $stableRev = null;
1112 protected $revsArePending = null;
1213 protected $pendingRevCount = null;
@@ -14,8 +15,6 @@
1516
1617 protected $imagePage = null; // for file pages
1718
18 - protected $stabilityDataLoaded = false;
19 -
2019 /**
2120 * Get a FlaggedArticle for a given title
2221 * @param Title
@@ -43,14 +42,14 @@
4443 * @return void
4544 */
4645 public function clear() {
 46+ $this->stable = 0;
4747 $this->stableRev = null;
4848 $this->revsArePending = null;
4949 $this->pendingRevCount = null;
5050 $this->pageConfig = null;
 51+ $this->syncedInTracking = null;
5152 $this->imagePage = null;
52 -
53 - $this->stabilityDataLoaded = false;
54 - parent::clear();
 53+ parent::clear(); // call super!
5554 }
5655
5756 /**
@@ -59,11 +58,11 @@
6059 * @return mixed (File/false)
6160 */
6261 public function getFile() {
63 - if ( $this->getTitle()->getNamespace() != NS_FILE ) {
 62+ if ( $this->mTitle->getNamespace() != NS_FILE ) {
6463 return false; // not a file page
6564 }
6665 if ( is_null( $this->imagePage ) ) {
67 - $this->imagePage = new ImagePage( $this->getTitle() );
 66+ $this->imagePage = new ImagePage( $this->mTitle );
6867 }
6968 return $this->imagePage->getFile();
7069 }
@@ -74,22 +73,20 @@
7574 * @return mixed (File/false)
7675 */
7776 public function getDisplayedFile() {
78 - if ( $this->getTitle()->getNamespace() != NS_FILE ) {
 77+ if ( $this->mTitle->getNamespace() != NS_FILE ) {
7978 return false; // not a file page
8079 }
8180 if ( is_null( $this->imagePage ) ) {
82 - $this->imagePage = new ImagePage( $this->getTitle() );
 81+ $this->imagePage = new ImagePage( $this->mTitle );
8382 }
8483 return $this->imagePage->getDisplayedFile();
8584 }
8685
8786 /**
8887 * Is the stable version shown by default for this page?
89 - * @param int $flags, FR_MASTER
9088 * @return bool
9189 */
92 - public function isStableShownByDefault( $flags = 0 ) {
93 - $this->loadFlaggedRevsData( $flags );
 90+ public function isStableShownByDefault() {
9491 if ( !$this->isReviewable() ) {
9592 return false; // no stable versions can exist
9693 }
@@ -99,11 +96,9 @@
10097
10198 /**
10299 * Do edits have to be reviewed before being shown by default (going live)?
103 - * @param int $flags, FR_MASTER
104100 * @return bool
105101 */
106 - public function editsRequireReview( $flags = 0 ) {
107 - $this->loadFlaggedRevsData( $flags );
 102+ public function editsRequireReview() {
108103 return (
109104 $this->isReviewable() && // reviewable page
110105 $this->isStableShownByDefault() && // and stable versions override
@@ -113,24 +108,28 @@
114109
115110 /**
116111 * Are edits to this page currently pending?
117 - * @param int $flags, FR_MASTER
118112 * @return bool
119113 */
120 - public function revsArePending( $flags = 0 ) {
121 - $this->loadFlaggedRevsData( $flags );
 114+ public function revsArePending() {
 115+ if ( !$this->mDataLoaded ) {
 116+ $this->loadPageData();
 117+ }
122118 return $this->revsArePending;
123119 }
124120
125121 /**
126122 * Get number of revs since the stable revision
127123 * Note: slower than revsArePending()
128 - * @param int $flags FR_MASTER
 124+ * @param int $flags FR_MASTER (be sure to use loadFromDB( FR_MASTER ) if set)
129125 * @return int
130126 */
131127 public function getPendingRevCount( $flags = 0 ) {
132128 global $wgMemc, $wgParserCacheExpireTime;
133 - $this->loadFlaggedRevsData( $flags );
134 - if ( !( $flags & FR_MASTER ) && $this->pendingRevCount !== null ) {
 129+ if ( !$this->mDataLoaded ) {
 130+ $this->loadPageData();
 131+ }
 132+ # Pending count deferred even after page data load
 133+ if ( $this->pendingRevCount !== null ) {
135134 return $this->pendingRevCount; // use process cache
136135 }
137136 $srev = $this->getStableRev();
@@ -185,7 +184,7 @@
186185 if ( $this->revsArePending() ) {
187186 return false;
188187 # Stable file revision must be the same as the current
189 - } elseif ( $this->getTitle()->getNamespace() == NS_FILE ) {
 188+ } elseif ( $this->mTitle->getNamespace() == NS_FILE ) {
190189 $file = $this->getFile(); // current upload version
191190 if ( $file && $file->getTimestamp() > $srev->getFileTimestamp() ) {
192191 return false;
@@ -251,11 +250,10 @@
252251
253252 /**
254253 * Is this article reviewable?
255 - * @param int $flags, FR_MASTER
256254 * @return bool
257255 */
258 - public function isReviewable( $flags = 0 ) {
259 - if ( !FlaggedRevs::inReviewNamespace( $this->getTitle() ) ) {
 256+ public function isReviewable() {
 257+ if ( !FlaggedRevs::inReviewNamespace( $this->mTitle ) ) {
260258 return false;
261259 }
262260 # Check if flagging is disabled for this page via config
@@ -268,105 +266,276 @@
269267
270268 /**
271269 * Is this page in patrollable?
272 - * @param int $flags, FR_MASTER
273270 * @return bool
274271 */
275 - public function isPatrollable( $flags = 0 ) {
276 - if ( !FlaggedRevs::inPatrolNamespace( $this->getTitle() ) ) {
 272+ public function isPatrollable() {
 273+ if ( !FlaggedRevs::inPatrolNamespace( $this->mTitle ) ) {
277274 return false;
278275 }
279 - return !$this->isReviewable( $flags ); // pages that are reviewable are not patrollable
 276+ return !$this->isReviewable(); // pages that are reviewable are not patrollable
280277 }
281278
282279 /**
283280 * Get the stable revision ID
284 - * @param int $flags
285281 * @return int
286282 */
287 - public function getStable( $flags = 0 ) {
288 - $srev = $this->getStableRev( $flags );
289 - return $srev ? $srev->getRevId() : 0;
 283+ public function getStable() {
 284+ if ( !$this->mDataLoaded ) {
 285+ $this->loadPageData();
 286+ }
 287+ return (int)$this->stable;
290288 }
291289
292290 /**
293291 * Get the stable revision
294 - * @param int $flags
295292 * @return mixed (FlaggedRevision/null)
296293 */
297 - public function getStableRev( $flags = 0 ) {
298 - $this->loadFlaggedRevsData( $flags );
 294+ public function getStableRev() {
 295+ if ( !$this->mDataLoaded ) {
 296+ $this->loadPageData();
 297+ }
 298+ # Stable rev deferred even after page data load
 299+ if ( $this->stableRev === null ) {
 300+ $srev = FlaggedRevision::newFromTitle( $this->mTitle, $this->stable );
 301+ $this->stableRev = $srev ? $srev : false; // cache negative hits too
 302+ }
299303 return $this->stableRev ? $this->stableRev : null; // false => null
300304 }
301305
302306 /**
303307 * Get visiblity restrictions on page
304 - * @param int $flags, FR_MASTER
305308 * @return Array (select,override)
306309 */
307 - public function getStabilitySettings( $flags = 0 ) {
308 - $this->loadFlaggedRevsData( $flags );
 310+ public function getStabilitySettings() {
 311+ if ( !$this->mDataLoaded ) {
 312+ $this->loadPageData();
 313+ }
309314 return $this->pageConfig;
310315 }
311316
 317+ /*
 318+ * Get the fp_reviewed value for this page
 319+ * @return bool
 320+ */
 321+ public function syncedInTracking() {
 322+ if ( !$this->mDataLoaded ) {
 323+ $this->loadPageData();
 324+ }
 325+ return $this->syncedInTracking;
 326+ }
 327+
312328 /**
313 - * Get a DB row of the stable version and page config of a title.
314 - * @param Title $title, page title
315 - * @param int $flags FR_MASTER
 329+ * Fetch a page record with the given conditions
 330+ * @param $dbr Database object
 331+ * @param $conditions Array
 332+ * @return mixed Database result resource, or false on failure
316333 */
317 - protected function loadFlaggedRevsData( $flags = 0 ) {
318 - if ( $this->stabilityDataLoaded && !( $flags & FR_MASTER ) ) {
319 - return; // no need to reload everything
320 - }
321 - $this->stabilityDataLoaded = true;
322 -
323 - $this->pageConfig = FlaggedPageConfig::getDefaultVisibilitySettings(); // default
324 - $this->stableRev = false; // false => "found nothing"
325 - $this->revsArePending = false;
326 - $this->pendingRevCount = null; // defer this one
327 -
328 - if ( !FlaggedRevs::inReviewNamespace( $this->getTitle() ) ) {
329 - return; // short-circuit
330 - }
331 - # User master/slave as appropriate...
332 - $db = ( $flags & FR_MASTER ) ?
333 - wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
334 - $row = $db->selectRow(
335 - array( 'page', 'flaggedpages', 'flaggedrevs', 'flaggedpage_config' ),
336 - array_merge( FlaggedRevision::selectFields(),
 334+ protected function pageData( $dbr, $conditions ) {
 335+ $row = $dbr->selectRow(
 336+ array( 'page', 'flaggedpages', 'flaggedpage_config' ),
 337+ array_merge(
 338+ Article::selectFields(),
337339 FlaggedPageConfig::selectFields(),
338 - array( 'fp_pending_since', 'fp_reviewed' ) ),
339 - array( 'page_id' => $this->getID() ),
 340+ array( 'fp_pending_since', 'fp_stable', 'fp_reviewed' ) ),
 341+ $conditions,
340342 __METHOD__,
341343 array(),
342344 array(
343 - 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ),
344 - 'flaggedrevs' => array( 'LEFT JOIN',
345 - 'fr_page_id = fp_page_id AND fr_rev_id = fp_stable' ),
 345+ 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ),
346346 'flaggedpage_config' => array( 'LEFT JOIN', 'fpc_page_id = page_id' ) )
347347 );
348 - if ( !$row ) {
349 - return; // no page found at all
 348+ return $row;
 349+ }
 350+
 351+ /**
 352+ * Set the page field data loaded from some source
 353+ * @param $data Database row object or "fromdb"
 354+ * @return void
 355+ */
 356+ public function loadPageData( $data = 'fromdb' ) {
 357+ $this->mDataLoaded = true; // sanity
 358+ # Fetch data from DB as needed...
 359+ if ( $data === 'fromdb' ) {
 360+ $data = $this->pageDataFromTitle( wfGetDB( DB_SLAVE ), $this->mTitle );
350361 }
351 - if ( $row->fpc_override !== null ) { // page config row found
352 - $this->pageConfig = FlaggedPageConfig::getVisibilitySettingsFromRow( $row );
 362+ # Load in primary page data...
 363+ parent::loadPageData( $data /* Row obj */ );
 364+ # Load in FlaggedRevs page data...
 365+ $this->stable = 0; // 0 => "found nothing"
 366+ $this->stableRev = null; // defer this one...
 367+ $this->revsArePending = false; // false => "found nothing" or "none pending"
 368+ $this->pendingRevCount = null; // defer this one...
 369+ $this->pageConfig = FlaggedPageConfig::getDefaultVisibilitySettings(); // default
 370+ $this->syncedInTracking = true; // false => "unreviewed" or "synced"
 371+ # Load in Row data if the page exists...
 372+ if ( $data ) {
 373+ if ( $data->fpc_override !== null ) { // page config row found
 374+ $this->pageConfig = FlaggedPageConfig::getVisibilitySettingsFromRow( $data );
 375+ }
 376+ if ( $data->fp_stable !== null ) { // stable rev found
 377+ $this->stable = (int)$data->fp_stable;
 378+ $this->revsArePending = ( $data->fp_pending_since !== null ); // revs await review
 379+ $this->syncedInTracking = (bool)$data->fp_reviewed;
 380+ }
353381 }
354 - if ( $row->fr_rev_id !== null ) { // stable rev row found
355 - // Page may not reviewable, which implies no stable version
356 - if ( !FlaggedRevs::useOnlyIfProtected() || $this->pageConfig['override'] ) {
357 - $this->stableRev = new FlaggedRevision( $row );
 382+ }
 383+
 384+ /**
 385+ * Set the page field data loaded from the DB
 386+ * @param int $flags FR_MASTER
 387+ * @param $data Database row object or "fromdb"
 388+ */
 389+ public function loadFromDB( $flags = 0 ) {
 390+ $db = ( $flags & FR_MASTER ) ?
 391+ wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
 392+ $this->loadPageData( $this->pageDataFromTitle( $db, $this->mTitle ) );
 393+ }
 394+
 395+ /**
 396+ * Updates the flagging tracking tables for this page
 397+ * @param FlaggedRevision $srev The new stable version
 398+ * @param mixed $latest The latest rev ID (optional)
 399+ * @return bool Updates were done
 400+ */
 401+ public function updateStableVersion( FlaggedRevision $srev, $latest = null ) {
 402+ $rev = $srev->getRevision();
 403+ if ( !$this->exists() || !$rev ) {
 404+ return false; // no bogus entries
 405+ }
 406+ # Get the latest revision ID if not set
 407+ if ( !$latest ) {
 408+ $latest = $this->mTitle->getLatestRevID( Title::GAID_FOR_UPDATE );
 409+ }
 410+ $dbw = wfGetDB( DB_MASTER );
 411+ # Get the highest quality revision (not necessarily this one)...
 412+ if ( $srev->getQuality() === FlaggedRevs::highestReviewTier() ) {
 413+ $maxQuality = $srev->getQuality(); // save a query
 414+ } else {
 415+ $maxQuality = $dbw->selectField( array( 'flaggedrevs', 'revision' ),
 416+ 'fr_quality',
 417+ array( 'fr_page_id' => $this->getId(),
 418+ 'rev_id = fr_rev_id',
 419+ 'rev_page = fr_page_id',
 420+ 'rev_deleted & ' . Revision::DELETED_TEXT => 0
 421+ ),
 422+ __METHOD__,
 423+ array( 'ORDER BY' => 'fr_quality DESC', 'LIMIT' => 1 )
 424+ );
 425+ $maxQuality = max( $maxQuality, $srev->getQuality() ); // sanity
 426+ }
 427+ # Get the timestamp of the first edit after the stable version (if any)...
 428+ $nextTimestamp = null;
 429+ if ( $rev->getId() != $latest ) {
 430+ $timestamp = $dbw->timestamp( $rev->getTimestamp() );
 431+ $nextEditTS = $dbw->selectField( 'revision',
 432+ 'rev_timestamp',
 433+ array(
 434+ 'rev_page' => $this->getId(),
 435+ "rev_timestamp > " . $dbw->addQuotes( $timestamp ) ),
 436+ __METHOD__,
 437+ array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
 438+ );
 439+ if ( $nextEditTS ) { // sanity check
 440+ $nextTimestamp = $nextEditTS;
358441 }
359442 }
360 - $this->revsArePending = ( $row->fp_pending_since !== null ); // revs await review
361 - $this->syncedInTracking = (bool)$row->fp_reviewed;
 443+ # Get the new page sync status...
 444+ $synced = !(
 445+ $nextTimestamp !== null || // edits pending
 446+ $srev->findPendingTemplateChanges() || // template changes pending
 447+ $srev->findPendingFileChanges( 'noForeign' ) // file changes pending
 448+ );
 449+ # Alter table metadata
 450+ $dbw->replace( 'flaggedpages',
 451+ array( 'fp_page_id' ),
 452+ array(
 453+ 'fp_page_id' => $this->getId(),
 454+ 'fp_stable' => $rev->getId(),
 455+ 'fp_reviewed' => $synced ? 1 : 0,
 456+ 'fp_quality' => ( $maxQuality === false ) ? null : $maxQuality,
 457+ 'fp_pending_since' => $dbw->timestampOrNull( $nextTimestamp )
 458+ ),
 459+ __METHOD__
 460+ );
 461+ # Update pending edit tracking table
 462+ self::updatePendingList( $this->getId(), $latest );
 463+ return true;
362464 }
363465
364 - /*
365 - * Get the fp_reviewed value for this page
366 - * @param int $flags FR_MASTER
367 - * @return bool
 466+ /**
 467+ * Updates the flagging tracking tables for this page
 468+ * @return void
368469 */
369 - public function syncedInTracking( $flags = 0 ) {
370 - $this->loadFlaggedRevsData( $flags );
371 - return $this->syncedInTracking;
 470+ public function clearStableVersion() {
 471+ if ( !$this->exists() ) {
 472+ return; // nothing to do
 473+ }
 474+ $dbw = wfGetDB( DB_MASTER );
 475+ $dbw->delete( 'flaggedpages',
 476+ array( 'fp_page_id' => $this->getId() ), __METHOD__ );
 477+ $dbw->delete( 'flaggedpage_pending',
 478+ array( 'fpp_page_id' => $this->getId() ), __METHOD__ );
372479 }
 480+
 481+ /**
 482+ * Updates the flaggedpage_pending table
 483+ * @param int $pageId Page ID
 484+ * @abstract int $latest Latest revision
 485+ * @return void
 486+ */
 487+ protected static function updatePendingList( $pageId, $latest ) {
 488+ $data = array();
 489+ $level = FlaggedRevs::highestReviewTier();
 490+ # Update pending times for each level, going from highest to lowest
 491+ $dbw = wfGetDB( DB_MASTER );
 492+ $higherLevelId = 0;
 493+ $higherLevelTS = '';
 494+ while ( $level >= 0 ) {
 495+ # Get the latest revision of this level...
 496+ $row = $dbw->selectRow( array( 'flaggedrevs', 'revision' ),
 497+ array( 'fr_rev_id', 'rev_timestamp' ),
 498+ array( 'fr_page_id' => $pageId,
 499+ 'fr_quality' => $level,
 500+ 'rev_id = fr_rev_id',
 501+ 'rev_page = fr_page_id',
 502+ 'rev_deleted & ' . Revision::DELETED_TEXT => 0,
 503+ 'rev_id > ' . intval( $higherLevelId )
 504+ ),
 505+ __METHOD__,
 506+ array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 )
 507+ );
 508+ # If there is a revision of this level, track it...
 509+ # Revisions reviewed to one level count as reviewed
 510+ # at the lower levels (i.e. quality -> checked).
 511+ if ( $row ) {
 512+ $id = $row->fr_rev_id;
 513+ $ts = $row->rev_timestamp;
 514+ } else {
 515+ $id = $higherLevelId; // use previous (quality -> checked)
 516+ $ts = $higherLevelTS; // use previous (quality -> checked)
 517+ }
 518+ # Get edits that actually are pending...
 519+ if ( $id && $latest > $id ) {
 520+ # Get the timestamp of the edit after this version (if any)
 521+ $nextTimestamp = $dbw->selectField( 'revision',
 522+ 'rev_timestamp',
 523+ array( 'rev_page' => $pageId, "rev_timestamp > " . $dbw->addQuotes( $ts ) ),
 524+ __METHOD__,
 525+ array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
 526+ );
 527+ $data[] = array(
 528+ 'fpp_page_id' => $pageId,
 529+ 'fpp_quality' => $level,
 530+ 'fpp_rev_id' => $id,
 531+ 'fpp_pending_since' => $nextTimestamp
 532+ );
 533+ $higherLevelId = $id;
 534+ $higherLevelTS = $ts;
 535+ }
 536+ $level--;
 537+ }
 538+ # Clear any old junk, and insert new rows
 539+ $dbw->delete( 'flaggedpage_pending', array( 'fpp_page_id' => $pageId ), __METHOD__ );
 540+ $dbw->insert( 'flaggedpage_pending', $data, __METHOD__ );
 541+ }
373542 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -171,6 +171,20 @@
172172 }
173173
174174 /**
 175+ * Get the highest review tier that is enabled
 176+ * @returns int One of FR_PRISTINE,FR_QUALITY,FR_CHECKED
 177+ */
 178+ public static function highestReviewTier() {
 179+ self::load();
 180+ if ( self::$pristineVersions ) {
 181+ return FR_PRISTINE;
 182+ } elseif ( self::$qualityVersions ) {
 183+ return FR_QUALITY;
 184+ }
 185+ return FR_CHECKED;
 186+ }
 187+
 188+ /**
175189 * Allow auto-review edits directly to the stable version by reviewers?
176190 * @returns bool
177191 */
@@ -720,19 +734,17 @@
721735 if ( $sv === null ) { // optional
722736 $sv = FlaggedRevision::determineStable( $title, FR_MASTER );
723737 }
 738+ $article = new FlaggedArticle( $title );
724739 if ( !$sv ) {
725740 # Empty flaggedrevs data for this page if there is no stable version
726 - self::clearTrackingRows( $title->getArticleID() );
 741+ $article->clearStableVersion();
727742 # Check if pages using this need to be refreshed...
728743 if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE ) {
729744 $changed = (bool)$oldSv;
730745 }
731746 } else {
732 - $article = new Article( $title );
733747 # Update flagged page related fields
734 - FlaggedRevs::updateStableVersion( $article, $sv );
735 - # Lazily rebuild dependancies on next parse (we invalidate below)
736 - FlaggedRevs::clearStableOnlyDeps( $title );
 748+ $article->updateStableVersion( $sv );
737749 # Check if pages using this need to be invalidated/purged...
738750 if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE ) {
739751 $changed = (
@@ -743,6 +755,8 @@
744756 );
745757 }
746758 }
 759+ # Lazily rebuild dependancies on next parse (we invalidate below)
 760+ FlaggedRevs::clearStableOnlyDeps( $title );
747761 # Clear page cache
748762 $title->invalidateCache();
749763 self::purgeSquid( $title );
@@ -759,143 +773,6 @@
760774 }
761775
762776 /**
763 - * @param Article $article
764 - * @param FlaggedRevision $srev, the new stable version
765 - * @param mixed $latest, the latest rev ID (optional)
766 - * Updates the tracking tables and pending edit count cache. Called on edit.
767 - */
768 - public static function updateStableVersion(
769 - Article $article, FlaggedRevision $srev, $latest = null
770 - ) {
771 - $rev = $srev->getRevision();
772 - if ( !$rev || !$article->getId() ) {
773 - return true; // no bogus entries
774 - }
775 - # Get the latest revision ID if not set
776 - if ( !$latest ) {
777 - $latest = $article->getTitle()->getLatestRevID( Title::GAID_FOR_UPDATE );
778 - }
779 - # Get the highest quality revision (not necessarily this one)
780 - $dbw = wfGetDB( DB_MASTER );
781 - $maxQuality = $dbw->selectField( array( 'flaggedrevs', 'revision' ),
782 - 'fr_quality',
783 - array( 'fr_page_id' => $article->getId(),
784 - 'rev_id = fr_rev_id',
785 - 'rev_page = fr_page_id',
786 - 'rev_deleted & ' . Revision::DELETED_TEXT => 0
787 - ),
788 - __METHOD__,
789 - array( 'ORDER BY' => 'fr_quality DESC', 'LIMIT' => 1 )
790 - );
791 - # Get the timestamp of the first edit after the stable version (if any)...
792 - $nextTimestamp = null;
793 - if ( $rev->getId() != $latest ) {
794 - $timestamp = $dbw->timestamp( $rev->getTimestamp() );
795 - $nextEditTS = $dbw->selectField( 'revision',
796 - 'rev_timestamp',
797 - array(
798 - 'rev_page' => $article->getId(),
799 - "rev_timestamp > " . $dbw->addQuotes( $timestamp ) ),
800 - __METHOD__,
801 - array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
802 - );
803 - if ( $nextEditTS ) { // sanity check
804 - $nextTimestamp = $nextEditTS;
805 - }
806 - }
807 - # Get the new page sync status...
808 - $synced = !(
809 - $nextTimestamp !== null || // edits pending
810 - $srev->findPendingTemplateChanges() || // template changes pending
811 - $srev->findPendingFileChanges( 'noForeign' ) // file changes pending
812 - );
813 - # Alter table metadata
814 - $dbw->replace( 'flaggedpages',
815 - array( 'fp_page_id' ),
816 - array(
817 - 'fp_page_id' => $article->getId(),
818 - 'fp_stable' => $rev->getId(),
819 - 'fp_reviewed' => $synced ? 1 : 0,
820 - 'fp_quality' => ( $maxQuality === false ) ? null : $maxQuality,
821 - 'fp_pending_since' => $dbw->timestampOrNull( $nextTimestamp )
822 - ),
823 - __METHOD__
824 - );
825 - # Update pending edit tracking table
826 - self::updatePendingList( $article, $latest );
827 - return true;
828 - }
829 -
830 - /**
831 - * @param Article $article
832 - * @param mixed $latest, the latest rev ID (optional)
833 - * Updates the flaggedpage_pending table
834 - */
835 - public static function updatePendingList( Article $article, $latest = null ) {
836 - $data = array();
837 - $level = self::pristineVersions() ? FR_PRISTINE : FR_QUALITY;
838 - if ( !self::qualityVersions() ) {
839 - $level = FR_CHECKED;
840 - }
841 - # Get the latest revision ID if not set
842 - if ( !$latest ) {
843 - $latest = $article->getTitle()->getLatestRevID( Title::GAID_FOR_UPDATE );
844 - }
845 - $pageId = $article->getId();
846 - # Update pending times for each level, going from highest to lowest
847 - $dbw = wfGetDB( DB_MASTER );
848 - $higherLevelId = 0;
849 - $higherLevelTS = '';
850 - while ( $level >= 0 ) {
851 - # Get the latest revision of this level...
852 - $row = $dbw->selectRow( array( 'flaggedrevs', 'revision' ),
853 - array( 'fr_rev_id', 'rev_timestamp' ),
854 - array( 'fr_page_id' => $pageId,
855 - 'fr_quality' => $level,
856 - 'rev_id = fr_rev_id',
857 - 'rev_page = fr_page_id',
858 - 'rev_deleted & ' . Revision::DELETED_TEXT => 0,
859 - 'rev_id > ' . intval( $higherLevelId )
860 - ),
861 - __METHOD__,
862 - array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 )
863 - );
864 - # If there is a revision of this level, track it...
865 - # Revisions reviewed to one level count as reviewed
866 - # at the lower levels (i.e. quality -> checked).
867 - if ( $row ) {
868 - $id = $row->fr_rev_id;
869 - $ts = $row->rev_timestamp;
870 - } else {
871 - $id = $higherLevelId; // use previous (quality -> checked)
872 - $ts = $higherLevelTS; // use previous (quality -> checked)
873 - }
874 - # Get edits that actually are pending...
875 - if ( $id && $latest > $id ) {
876 - # Get the timestamp of the edit after this version (if any)
877 - $nextTimestamp = $dbw->selectField( 'revision',
878 - 'rev_timestamp',
879 - array( 'rev_page' => $pageId, "rev_timestamp > " . $dbw->addQuotes( $ts ) ),
880 - __METHOD__,
881 - array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
882 - );
883 - $data[] = array(
884 - 'fpp_page_id' => $pageId,
885 - 'fpp_quality' => $level,
886 - 'fpp_rev_id' => $id,
887 - 'fpp_pending_since' => $nextTimestamp
888 - );
889 - $higherLevelId = $id;
890 - $higherLevelTS = $ts;
891 - }
892 - $level--;
893 - }
894 - # Clear any old junk, and insert new rows
895 - $dbw->delete( 'flaggedpage_pending', array( 'fpp_page_id' => $pageId ), __METHOD__ );
896 - $dbw->insert( 'flaggedpage_pending', $data, __METHOD__ );
897 - }
898 -
899 - /**
900777 * Do cache updates for when the stable version of a page changed.
901778 * Invalidates/purges pages that include the given page.
902779 * @param Title $title
Index: trunk/extensions/FlaggedRevs/business/PageStabilityForm.php
@@ -224,26 +224,36 @@
225225 $changed = FlaggedPageConfig::setStabilitySettings( $this->page, $this->getNewConfig() );
226226 # Log if this actually changed anything...
227227 if ( $changed ) {
 228+ $article = new FlaggedArticle( $this->page );
 229+ if ( FlaggedRevs::useOnlyIfProtected() ) {
 230+ # Config may have changed to allow stable versions, so refresh
 231+ # the tracking table to account for any hidden reviewed versions...
 232+ $frev = FlaggedRevision::determineStable( $this->page, FR_MASTER );
 233+ if ( $frev ) {
 234+ $article->updateStableVersion( $frev );
 235+ } else {
 236+ $article->clearStableVersion();
 237+ }
 238+ }
228239 # Update logs and make a null edit
229 - $nullRev = $this->updateLogsAndHistory();
230 - if ( $this->reviewThis ) {
231 - # Null edit may have been auto-reviewed already
232 - $frev = FlaggedRevision::newFromTitle(
233 - $this->page, $nullRev->getId(), FR_MASTER );
234 - # Check if this null edit is to be reviewed...
235 - if ( !$frev ) {
236 - $flags = null;
237 - $article = new Article( $this->page );
238 - # Review this revision of the page...
239 - $ok = FlaggedRevs::autoReviewEdit(
240 - $article, $this->user, $nullRev, $flags, true );
241 - if ( $ok ) {
242 - FlaggedRevs::markRevisionPatrolled( $nullRev ); // reviewed -> patrolled
243 - }
 240+ $nullRev = $this->updateLogsAndHistory( $article );
 241+ # Null edit may have been auto-reviewed already
 242+ $frev = FlaggedRevision::newFromTitle( $this->page, $nullRev->getId(), FR_MASTER );
 243+ $updatesDone = (bool)$frev; // stableVersionUpdates() already called?
 244+ # Check if this null edit is to be reviewed...
 245+ if ( $this->reviewThis && !$frev ) {
 246+ $flags = null;
 247+ # Review this revision of the page...
 248+ $ok = FlaggedRevs::autoReviewEdit( $article, $this->user, $nullRev, $flags, true );
 249+ if ( $ok ) {
 250+ FlaggedRevs::markRevisionPatrolled( $nullRev ); // reviewed -> patrolled
 251+ $updatesDone = true; // stableVersionUpdates() already called
244252 }
245253 }
246 - # Update page and tracking tables and clear cache
247 - FlaggedRevs::stableVersionUpdates( $this->page );
 254+ # Update page and tracking tables and clear cache.
 255+ if ( !$updatesDone ) {
 256+ FlaggedRevs::stableVersionUpdates( $this->page );
 257+ }
248258 }
249259 # Apply watchlist checkbox value (may be NULL)
250260 $this->updateWatchlist();
@@ -258,24 +268,12 @@
259269 * (b) Add a null edit like the log entry
260270 * @return Revision
261271 */
262 - protected function updateLogsAndHistory() {
 272+ protected function updateLogsAndHistory( FlaggedArticle $article ) {
263273 global $wgContLang;
264 - $article = new Article( $this->page );
265274 $newConfig = $this->getNewConfig();
266275 $oldConfig = $this->getOldConfig();
267276 $reason = $this->getReason();
268277
269 - if ( FlaggedRevs::useOnlyIfProtected() ) {
270 - # Config may have changed to allow stable versions, so refresh
271 - # the tracking table to account for any hidden reviewed versions...
272 - $frev = FlaggedRevision::determineStable( $this->page, FR_MASTER );
273 - if ( $frev ) {
274 - FlaggedRevs::updateStableVersion( $article, $frev );
275 - } else {
276 - FlaggedRevs::clearTrackingRows( $article->getId() );
277 - }
278 - }
279 -
280278 # Insert stability log entry...
281279 FlaggedRevsLog::updateStabilityLog( $this->page, $newConfig, $oldConfig, $reason );
282280
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -26,7 +26,7 @@
2727 private $mStableFiles;
2828
2929 /**
30 - * @param mixed $row (DB row or array)
 30+ * @param Row|array $row (DB row or array)
3131 * @return void
3232 */
3333 public function __construct( $row ) {
@@ -38,6 +38,8 @@
3939 $this->mTags = self::expandRevisionTags( strval( $row->fr_tags ) );
4040 $this->mFlags = explode( ',', $row->fr_flags );
4141 $this->mUser = intval( $row->fr_user );
 42+ # Base Revision object
 43+ $this->mRevision = new Revision( $row );
4244 # Image page revision relevant params
4345 $this->mFileName = $row->fr_img_name ? $row->fr_img_name : null;
4446 $this->mFileSha1 = $row->fr_img_sha1 ? $row->fr_img_sha1 : null;
@@ -76,7 +78,7 @@
7779 * @param Title $title
7880 * @param int $revId
7981 * @param int $flags (FR_MASTER, FR_FOR_UPDATE)
80 - * @return mixed FlaggedRevision (null on failure)
 82+ * @return FlaggedRevision|null (null on failure)
8183 */
8284 public static function newFromTitle( Title $title, $revId, $flags = 0 ) {
8385 if ( !FlaggedRevs::inReviewNamespace( $title ) ) {
@@ -92,13 +94,15 @@
9395 $db = wfGetDB( DB_SLAVE );
9496 $pageId = $title->getArticleID();
9597 }
96 - if ( !$pageId ) {
 98+ if ( !$pageId || !$revId ) {
9799 return null; // short-circuit query
98100 }
99101 # Skip deleted revisions
100 - $row = $db->selectRow( array( 'flaggedrevs', 'revision' ),
 102+ $row = $db->selectRow(
 103+ array( 'flaggedrevs', 'revision' ),
101104 self::selectFields(),
102 - array( 'fr_page_id' => $pageId,
 105+ array(
 106+ 'fr_page_id' => $pageId,
103107 'fr_rev_id' => $revId,
104108 'rev_id = fr_rev_id',
105109 'rev_page = fr_page_id',
@@ -120,7 +124,7 @@
121125 * Get a FlaggedRevision of the stable version of a title.
122126 * @param Title $title, page title
123127 * @param int $flags (FR_MASTER, FR_FOR_UPDATE)
124 - * @return mixed FlaggedRevision (null on failure)
 128+ * @return FlaggedRevision|null (null on failure)
125129 */
126130 public static function newFromStable( Title $title, $flags = 0 ) {
127131 if ( !FlaggedRevs::inReviewNamespace( $title ) ) {
@@ -141,21 +145,23 @@
142146 }
143147 # Check tracking tables
144148 $row = $db->selectRow(
145 - array( 'flaggedpages', 'flaggedrevs' ),
 149+ array( 'flaggedpages', 'flaggedrevs', 'revision' ),
146150 self::selectFields(),
147 - array( 'fp_page_id' => $pageId,
 151+ array(
 152+ 'fp_page_id' => $pageId,
148153 'fr_page_id = fp_page_id',
149 - 'fr_rev_id = fp_stable'
 154+ 'fr_rev_id = fp_stable',
 155+ 'rev_id = fr_rev_id'
150156 ),
151157 __METHOD__,
152158 $options
153159 );
154 - if ( !$row ) {
155 - return null;
 160+ if ( $row ) {
 161+ $frev = new self( $row );
 162+ $frev->mTitle = $title;
 163+ return $frev;
156164 }
157 - $frev = new self( $row );
158 - $frev->mTitle = $title;
159 - return $frev;
 165+ return null;
160166 }
161167
162168 /**
@@ -165,7 +171,7 @@
166172 * @param int $flags (FR_MASTER, FR_FOR_UPDATE)
167173 * @param array $config, optional page config (use to skip queries)
168174 * @param string $precedence (latest,quality,pristine)
169 - * @return mixed FlaggedRevision (null on failure)
 175+ * @return FlaggedRevision|null (null on failure)
170176 */
171177 public static function determineStable(
172178 Title $title, $flags = 0, $config = array(), $precedence = 'latest'
@@ -194,13 +200,12 @@
195201 return null; // page is not reviewable; no stable version
196202 }
197203 $row = null;
198 - $columns = self::selectFields();
199204 $options['ORDER BY'] = 'fr_rev_id DESC';
200205 # Look for the latest pristine revision...
201206 if ( FlaggedRevs::pristineVersions() && $precedence !== 'latest' ) {
202207 $prow = $db->selectRow(
203208 array( 'flaggedrevs', 'revision' ),
204 - $columns,
 209+ self::selectFields(),
205210 array( 'fr_page_id' => $pageId,
206211 'fr_quality = ' . FR_PRISTINE,
207212 'rev_id = fr_rev_id',
@@ -221,7 +226,7 @@
222227 $newerClause = $row ? "fr_rev_id > {$row->fr_rev_id}" : "1 = 1";
223228 $qrow = $db->selectRow(
224229 array( 'flaggedrevs', 'revision' ),
225 - $columns,
 230+ self::selectFields(),
226231 array( 'fr_page_id' => $pageId,
227232 'fr_quality = ' . FR_QUALITY,
228233 $newerClause,
@@ -238,7 +243,7 @@
239244 if ( !$row ) {
240245 $row = $db->selectRow(
241246 array( 'flaggedrevs', 'revision' ),
242 - $columns,
 247+ self::selectFields(),
243248 array( 'fr_page_id' => $pageId,
244249 'rev_id = fr_rev_id',
245250 'rev_page = fr_page_id',
@@ -321,12 +326,14 @@
322327 }
323328
324329 /**
325 - * @return Array basic select fields for FlaggedRevision DB row
 330+ * Get select fields for FlaggedRevision DB row (flaggedrevs/revision tables)
 331+ * @return Array
326332 */
327333 public static function selectFields() {
328 - return array(
329 - 'fr_rev_id', 'fr_page_id', 'fr_user', 'fr_timestamp', 'fr_quality',
330 - 'fr_tags', 'fr_flags', 'fr_img_name', 'fr_img_sha1', 'fr_img_timestamp',
 334+ return array_merge(
 335+ Revision::selectFields(),
 336+ array( 'fr_rev_id', 'fr_page_id', 'fr_user', 'fr_timestamp', 'fr_quality',
 337+ 'fr_tags', 'fr_flags', 'fr_img_name', 'fr_img_sha1', 'fr_img_timestamp' )
331338 );
332339 }
333340
@@ -730,7 +737,7 @@
731738
732739 /**
733740 * Get text of the corresponding revision
734 - * @return mixed (string/false) revision timestamp in MW format
 741+ * @return string|false revision timestamp in MW format
735742 */
736743 public function getRevText() {
737744 # Get corresponding revision
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -204,8 +204,9 @@
205205 Title $otitle, Title $ntitle, $user, $pageId
206206 ) {
207207 $fa = FlaggedArticle::getTitleInstance( $ntitle );
 208+ $fa->loadFromDB( FR_MASTER );
208209 // Re-validate NS/config (new title may not be reviewable)
209 - if ( $fa->isReviewable( FR_MASTER ) ) {
 210+ if ( $fa->isReviewable() ) {
210211 // Moved from non-reviewable to reviewable NS?
211212 // Auto-review such edits like new pages...
212213 if ( !FlaggedRevs::inReviewNamespace( $otitle )
@@ -485,7 +486,8 @@
486487 global $wgRequest;
487488 # Edit must be non-null, to a reviewable page, with $user set
488489 $fa = FlaggedArticle::getArticleInstance( $article );
489 - if ( !$rev || !$user || !$fa->isReviewable( FR_MASTER ) ) {
 490+ $fa->loadFromDB( FR_MASTER );
 491+ if ( !$rev || !$user || !$fa->isReviewable() ) {
490492 return true;
491493 }
492494 $title = $article->getTitle(); // convenience
@@ -556,7 +558,7 @@
557559 # (a) this is a rollback to the stable version
558560 # (b) this is a self-reversion to the stable version
559561 # These are subcases of making a new revision based on an old, reviewed, revision.
560 - } elseif ( FlaggedRevs::autoReviewEdits() && $fa->getStableRev( FR_MASTER ) ) {
 562+ } elseif ( FlaggedRevs::autoReviewEdits() && $fa->getStableRev() ) {
561563 $srev = $fa->getStableRev();
562564 # Check for rollbacks...
563565 $reviewableChange = (
@@ -660,7 +662,8 @@
661663 return true;
662664 }
663665 $fa = FlaggedArticle::getArticleInstance( $article );
664 - if ( !$fa->isReviewable( FR_MASTER ) ) {
 666+ $fa->loadFromDB( FR_MASTER );
 667+ if ( !$fa->isReviewable() ) {
665668 return true; // page is not reviewable
666669 }
667670 $title = $article->getTitle(); // convenience
@@ -724,8 +727,9 @@
725728 return true;
726729 }
727730 $fa = FlaggedArticle::getTitleInstance( $rc->getTitle() );
 731+ $fa->loadFromDB( FR_MASTER );
728732 // Is the page reviewable?
729 - if ( $fa->isReviewable( FR_MASTER ) ) {
 733+ if ( $fa->isReviewable() ) {
730734 $revId = $rc->mAttribs['rc_this_oldid'];
731735 $quality = FlaggedRevs::getRevQuality(
732736 $rc->mAttribs['rc_cur_id'], $revId, FR_MASTER );
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedArticleView.php
@@ -1597,8 +1597,9 @@
15981598 public function injectPostEditURLParams( &$sectionAnchor, &$extraQuery ) {
15991599 global $wgUser;
16001600 $this->load();
 1601+ $this->article->loadFromDB( FR_MASTER );
16011602 # Get the stable version from the master
1602 - $frev = $this->article->getStableRev( FR_MASTER );
 1603+ $frev = $this->article->getStableRev();
16031604 if ( !$frev || !$this->article->revsArePending() ) {
16041605 return true; // only for pages with pending edits
16051606 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85913* Made pageDataFromTitle protected (unused elsewhere)...aaron20:21, 12 April 2011

Status & tagging log