Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -597,14 +597,11 @@ |
598 | 598 | Article $article, $rev, $baseRevId = false, $user = null |
599 | 599 | ) { |
600 | 600 | global $wgRequest; |
601 | | - # Edit must be non-null, and to a reviewable page |
| 601 | + # Edit must be non-null, to a reviewable page, with $user set |
602 | 602 | $fa = FlaggedArticle::getArticleInstance( $article ); |
603 | | - if ( !$rev || !$fa->isReviewable( FR_MASTER ) ) { |
| 603 | + if ( !$rev || !$user || !$fa->isReviewable( FR_MASTER ) ) { |
604 | 604 | return true; |
605 | 605 | } |
606 | | - if ( !$user ) { |
607 | | - $user = User::newFromId( $rev->getUser() ); |
608 | | - } |
609 | 606 | $title = $article->getTitle(); // convenience |
610 | 607 | $title->resetArticleID( $rev->getPage() ); // Avoid extra DB hit and lag issues |
611 | 608 | # Get what was just the current revision ID |
— | — | @@ -615,7 +612,7 @@ |
616 | 613 | # Is the page manually checked off to be reviewed? |
617 | 614 | if ( $editTimestamp |
618 | 615 | && $wgRequest->getCheck( 'wpReviewEdit' ) |
619 | | - && $title->userCan( 'review' ) ) |
| 616 | + && $title->getUserPermissionsErrors( 'review', $user ) === array() ) |
620 | 617 | { |
621 | 618 | if ( self::editCheckReview( $article, $rev, $user, $editTimestamp ) ) { |
622 | 619 | return true; // reviewed...done! |
— | — | @@ -643,37 +640,37 @@ |
644 | 641 | $baseRevId = $prevRevId; |
645 | 642 | } |
646 | 643 | } |
647 | | - # Self-reversions to the stable version by anyone can be auto-reviewed... |
648 | | - $srev = $fa->getStableRev( FR_MASTER ); |
649 | | - if ( $srev && self::isSelfRevertToStable( $rev, $srev, $baseRevId, $user ) ) { |
650 | | - $flags = $srev->getTags(); // use old tags |
651 | | - # Review this revision of the page... |
652 | | - FlaggedRevs::autoReviewEdit( $article, $user, $rev, $flags ); |
653 | | - return true; // done! |
654 | | - } |
655 | | - # Can this user auto-review this page? |
656 | | - $isAllowed = $title->getUserPermissionsErrors( 'autoreview', $user ) === array(); |
657 | | - if ( !$isAllowed ) { |
658 | | - return true; // user does not have auto-review rights |
659 | | - } |
660 | | - $reviewableNewPage = false; |
661 | | - // New pages |
662 | | - if ( !$prevRevId ) { |
663 | | - $reviewableNewPage = FlaggedRevs::autoReviewNewPages(); |
664 | | - // Edits to existing pages |
665 | | - } elseif ( $baseRevId ) { |
666 | | - # Check if the base revision was reviewed... |
667 | | - $frev = ( $srev && $srev->getRevId() == $baseRevId ) |
668 | | - ? $srev // save ourselves a query |
669 | | - : FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER ); |
670 | | - } |
671 | | - // Is this an edit directly to the stable version? Is it a new page? |
672 | | - if ( $isAllowed && ( $reviewableNewPage || $frev ) ) { |
673 | | - if ( $isNullEdit && $frev ) { |
674 | | - $flags = $frev->getTags(); // Dummy edits always keep previous tags |
| 644 | + # Case A: this user can auto-review edits. Check if either: |
| 645 | + # (a) this new revision creates a new page and new page autoreview is enabled |
| 646 | + # (b) this new revision is based on an old, reviewed, revision |
| 647 | + if ( $title->getUserPermissionsErrors( 'autoreview', $user ) === array() ) { |
| 648 | + // New pages |
| 649 | + if ( !$prevRevId ) { |
| 650 | + $reviewableNewPage = FlaggedRevs::autoReviewNewPages(); |
| 651 | + // Edits to existing pages |
| 652 | + } elseif ( $baseRevId ) { |
| 653 | + $reviewableNewPage = false; // had previous rev |
| 654 | + # Check if the base revision was reviewed... |
| 655 | + $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER ); |
675 | 656 | } |
676 | | - # Review this revision of the page... |
677 | | - FlaggedRevs::autoReviewEdit( $article, $user, $rev, $flags ); |
| 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 |
| 661 | + } |
| 662 | + # Review this revision of the page... |
| 663 | + FlaggedRevs::autoReviewEdit( $article, $user, $rev, $flags ); |
| 664 | + } |
| 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 ) ) { |
| 671 | + $flags = $srev->getTags(); // use old tags |
| 672 | + # Review this revision of the page... |
| 673 | + FlaggedRevs::autoReviewEdit( $article, $user, $rev, $flags ); |
| 674 | + } |
678 | 675 | } |
679 | 676 | return true; |
680 | 677 | } |