r100149 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100148‎ | r100149 | r100150 >
Date:19:57, 18 October 2011
Author:aaron
Status:ok
Tags:
Comment:
Made updatePendingList() order by timestamp instead of rev ID for robustness
Modified paths:
  • /trunk/extensions/FlaggedRevs/dataclasses/FlaggableWikiPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggableWikiPage.php
@@ -496,34 +496,42 @@
497497 */
498498 protected static function updatePendingList( $pageId, $latest ) {
499499 $data = array();
 500+ # Get the highest tier used on this wiki
500501 $level = FlaggedRevs::highestReviewTier();
 502+
 503+ $dbw = wfGetDB( DB_MASTER );
501504 # Update pending times for each level, going from highest to lowest
502 - $dbw = wfGetDB( DB_MASTER );
503505 $higherLevelId = 0;
504506 $higherLevelTS = '';
505507 while ( $level >= 0 ) {
506508 # Get the latest revision of this level...
507 - $row = $dbw->selectRow( array( 'flaggedrevs', 'revision' ),
 509+ # Any revision of one tier is also a revision of lower tiers.
 510+ # Instead of doing fr_quality > X queries we do exact comparisons
 511+ # for better INDEX usage. However, in order to treat a rev as the
 512+ # latest tier X rev, we make sure it is newer than all tier (X+1) revs.
 513+ $row = $dbw->selectRow(
 514+ array( 'flaggedrevs', 'revision' ),
508515 array( 'fr_rev_id', 'rev_timestamp' ),
509 - array( 'fr_page_id' => $pageId,
510 - 'fr_quality' => $level,
511 - 'rev_id = fr_rev_id',
512 - 'rev_page = fr_page_id',
513 - 'rev_deleted & ' . Revision::DELETED_TEXT => 0,
514 - 'rev_id > ' . intval( $higherLevelId )
 516+ array(
 517+ 'fr_page_id' => $pageId,
 518+ 'fr_quality' => $level, // this level
 519+ 'fr_rev_timestamp > ' . $dbw->addQuotes( $higherLevelTS ),
 520+ 'rev_id = fr_rev_id', // rev exists
 521+ 'rev_page = fr_page_id', // sanity
 522+ 'rev_deleted & ' . Revision::DELETED_TEXT => 0
515523 ),
516524 __METHOD__,
517 - array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 )
 525+ array( 'ORDER BY' => 'fr_rev_timestamp DESC', 'LIMIT' => 1 )
518526 );
519527 # If there is a revision of this level, track it...
520 - # Revisions reviewed to one level count as reviewed
521 - # at the lower levels (i.e. quality -> checked).
 528+ # Revisions accepted to one tier count as accepted
 529+ # at the lower tiers (i.e. quality -> checked).
522530 if ( $row ) {
523531 $id = $row->fr_rev_id;
524532 $ts = $row->rev_timestamp;
525 - } else {
526 - $id = $higherLevelId; // use previous (quality -> checked)
527 - $ts = $higherLevelTS; // use previous (quality -> checked)
 533+ } else { // use previous rev of higher tier (if any)
 534+ $id = $higherLevelId;
 535+ $ts = $higherLevelTS;
528536 }
529537 # Get edits that actually are pending...
530538 if ( $id && $latest > $id ) {

Status & tagging log