Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggableWikiPage.php |
— | — | @@ -496,34 +496,42 @@ |
497 | 497 | */ |
498 | 498 | protected static function updatePendingList( $pageId, $latest ) { |
499 | 499 | $data = array(); |
| 500 | + # Get the highest tier used on this wiki |
500 | 501 | $level = FlaggedRevs::highestReviewTier(); |
| 502 | + |
| 503 | + $dbw = wfGetDB( DB_MASTER ); |
501 | 504 | # Update pending times for each level, going from highest to lowest |
502 | | - $dbw = wfGetDB( DB_MASTER ); |
503 | 505 | $higherLevelId = 0; |
504 | 506 | $higherLevelTS = ''; |
505 | 507 | while ( $level >= 0 ) { |
506 | 508 | # 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' ), |
508 | 515 | 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 |
515 | 523 | ), |
516 | 524 | __METHOD__, |
517 | | - array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) |
| 525 | + array( 'ORDER BY' => 'fr_rev_timestamp DESC', 'LIMIT' => 1 ) |
518 | 526 | ); |
519 | 527 | # 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). |
522 | 530 | if ( $row ) { |
523 | 531 | $id = $row->fr_rev_id; |
524 | 532 | $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; |
528 | 536 | } |
529 | 537 | # Get edits that actually are pending... |
530 | 538 | if ( $id && $latest > $id ) { |