Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -234,12 +234,13 @@ |
235 | 235 | $wgGroupPermissions['bot']['autoreview'] = true; |
236 | 236 | |
237 | 237 | # 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 |
244 | 245 | |
245 | 246 | $wgExtensionFunctions[] = 'efLoadFlaggedRevs'; |
246 | 247 | |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -606,7 +606,6 @@ |
607 | 607 | $title->resetArticleID( $rev->getPage() ); // Avoid extra DB hit and lag issues |
608 | 608 | # Get what was just the current revision ID |
609 | 609 | $prevRevId = $rev->getParentId(); |
610 | | - $frev = $flags = null; |
611 | 610 | # Get edit timestamp. Existance already validated by EditPage.php. |
612 | 611 | $editTimestamp = $wgRequest->getVal( 'wpEdittime' ); |
613 | 612 | # Is the page manually checked off to be reviewed? |
— | — | @@ -622,8 +621,8 @@ |
623 | 622 | if ( !FlaggedRevs::autoReviewEdits() ) { |
624 | 623 | return true; |
625 | 624 | } |
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 |
628 | 627 | # Get the revision ID the incoming one was based off... |
629 | 628 | if ( !$baseRevId && $prevRevId ) { |
630 | 629 | $prevTimestamp = Revision::getTimestampFromId( $title, $prevRevId ); |
— | — | @@ -640,6 +639,8 @@ |
641 | 640 | $baseRevId = $prevRevId; |
642 | 641 | } |
643 | 642 | } |
| 643 | + $frev = null; // flagged rev this edit was based on |
| 644 | + $flags = null; // review flags (null => default flags) |
644 | 645 | # Case A: this user can auto-review edits. Check if either: |
645 | 646 | # (a) this new revision creates a new page and new page autoreview is enabled |
646 | 647 | # (b) this new revision is based on an old, reviewed, revision |
— | — | @@ -647,26 +648,41 @@ |
648 | 649 | // New pages |
649 | 650 | if ( !$prevRevId ) { |
650 | 651 | $reviewableNewPage = FlaggedRevs::autoReviewNewPages(); |
| 652 | + $reviewableChange = false; |
651 | 653 | // Edits to existing pages |
652 | 654 | } elseif ( $baseRevId ) { |
653 | 655 | $reviewableNewPage = false; // had previous rev |
654 | 656 | # Check if the base revision was reviewed... |
655 | 657 | $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER ); |
| 658 | + $reviewableChange = (bool)$frev; |
656 | 659 | } |
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 |
661 | 664 | } |
662 | 665 | # Review this revision of the page... |
663 | 666 | FlaggedRevs::autoReviewEdit( $article, $user, $rev, $flags ); |
664 | 667 | } |
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 ) { |
671 | 687 | $flags = $srev->getTags(); // use old tags |
672 | 688 | # Review this revision of the page... |
673 | 689 | FlaggedRevs::autoReviewEdit( $article, $user, $rev, $flags ); |