r84166 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84165‎ | r84166 | r84167 >
Date:13:56, 17 March 2011
Author:aaron
Status:ok
Tags:
Comment:
(bug 27582) Implement new right that makes rollbacks autoreview the page (if rolled back to the stable version)
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -234,12 +234,13 @@
235235 $wgGroupPermissions['bot']['autoreview'] = true;
236236
237237 # Lets some users access the review UI and set some flags
238 -$wgAvailableRights[] = 'review';
239 -$wgAvailableRights[] = 'validate'; # Let some users set higher settings
240 -$wgAvailableRights[] = 'autoreview';
241 -$wgAvailableRights[] = 'unreviewedpages';
242 -$wgAvailableRights[] = 'movestable';
243 -$wgAvailableRights[] = 'stablesettings';
 238+$wgAvailableRights[] = 'review'; # review pages to basic levels
 239+$wgAvailableRights[] = 'validate'; # review pages to all levels
 240+$wgAvailableRights[] = 'autoreview'; # auto-review pages on edit (including rollback)
 241+$wgAvailableRights[] = 'autoreviewrestore'; # auto-review on rollback
 242+$wgAvailableRights[] = 'unreviewedpages'; # view the list of unreviewed pages
 243+$wgAvailableRights[] = 'movestable'; # move pages with stable versions
 244+$wgAvailableRights[] = 'stablesettings'; # change page stability settings
244245
245246 $wgExtensionFunctions[] = 'efLoadFlaggedRevs';
246247
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -606,7 +606,6 @@
607607 $title->resetArticleID( $rev->getPage() ); // Avoid extra DB hit and lag issues
608608 # Get what was just the current revision ID
609609 $prevRevId = $rev->getParentId();
610 - $frev = $flags = null;
611610 # Get edit timestamp. Existance already validated by EditPage.php.
612611 $editTimestamp = $wgRequest->getVal( 'wpEdittime' );
613612 # Is the page manually checked off to be reviewed?
@@ -622,8 +621,8 @@
623622 if ( !FlaggedRevs::autoReviewEdits() ) {
624623 return true;
625624 }
626 - # If a $baseRevId is passed in this is a null edit
627 - $isNullEdit = (bool)$baseRevId;
 625+ # If a $baseRevId is passed in, the edit is using an old revision's text
 626+ $isOldRevCopy = (bool)$baseRevId; // null edit or rollback
628627 # Get the revision ID the incoming one was based off...
629628 if ( !$baseRevId && $prevRevId ) {
630629 $prevTimestamp = Revision::getTimestampFromId( $title, $prevRevId );
@@ -640,6 +639,8 @@
641640 $baseRevId = $prevRevId;
642641 }
643642 }
 643+ $frev = null; // flagged rev this edit was based on
 644+ $flags = null; // review flags (null => default flags)
644645 # Case A: this user can auto-review edits. Check if either:
645646 # (a) this new revision creates a new page and new page autoreview is enabled
646647 # (b) this new revision is based on an old, reviewed, revision
@@ -647,26 +648,41 @@
648649 // New pages
649650 if ( !$prevRevId ) {
650651 $reviewableNewPage = FlaggedRevs::autoReviewNewPages();
 652+ $reviewableChange = false;
651653 // Edits to existing pages
652654 } elseif ( $baseRevId ) {
653655 $reviewableNewPage = false; // had previous rev
654656 # Check if the base revision was reviewed...
655657 $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER );
 658+ $reviewableChange = (bool)$frev;
656659 }
657 - // Is this an edit directly to the stable version? Is it a new page?
658 - if ( $reviewableNewPage || $frev ) {
659 - if ( $isNullEdit && $frev ) {
660 - $flags = $frev->getTags(); // dummy edits always keep previous tags
 660+ // Is this an edit directly to a reviewed version or a new page?
 661+ if ( $reviewableNewPage || $reviewableChange ) {
 662+ if ( $isOldRevCopy && $frev ) {
 663+ $flags = $frev->getTags(); // null edits & rollbacks keep previous tags
661664 }
662665 # Review this revision of the page...
663666 FlaggedRevs::autoReviewEdit( $article, $user, $rev, $flags );
664667 }
665 - # Case B: the user cannot autoreview edits. Check if this is a
666 - # self-reversion to the stable version. Note that this is a subcase
667 - # of making a new revision based on an old, reviewed, revision.
668 - } else {
669 - $srev = $fa->getStableRev( FR_MASTER );
670 - if ( $srev && self::isSelfRevertToStable( $rev, $srev, $baseRevId, $user ) ) {
 668+ # Case B: the user cannot autoreview edits. Check if either:
 669+ # (a) this is a rollback to the stable version
 670+ # (b) this is a self-reversion to the stable version
 671+ # These are subcases of making a new revision based on an old, reviewed, revision.
 672+ } elseif ( $fa->getStableRev( FR_MASTER ) ) {
 673+ $srev = $fa->getStableRev();
 674+ # Check for rollbacks...
 675+ $reviewableChange = (
 676+ $isOldRevCopy && // rollback or null edit
 677+ $baseRevId != $prevRevId && // not a null edit
 678+ $baseRevId == $srev->getRevId() && // restored stable rev
 679+ $title->getUserPermissionsErrors( 'autoreviewrestore', $user ) === array()
 680+ );
 681+ # Check for self-reversions...
 682+ if ( !$reviewableChange ) {
 683+ $reviewableChange = self::isSelfRevertToStable( $rev, $srev, $baseRevId, $user );
 684+ }
 685+ // Is this a rollback or self-reversion to the stable rev?
 686+ if ( $reviewableChange ) {
671687 $flags = $srev->getTags(); // use old tags
672688 # Review this revision of the page...
673689 FlaggedRevs::autoReviewEdit( $article, $user, $rev, $flags );

Follow-up revisions

RevisionCommit summaryAuthorDate
r84232Follow-up r84166: Add description message for the new user rightraymond12:45, 18 March 2011

Status & tagging log