Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -68,33 +68,24 @@ |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Is this article reviewable? |
72 | | - * @param bool $titleOnly, only check if title is in reviewable namespace |
| 72 | + * @returns bool |
73 | 73 | */ |
74 | | - public function isReviewable( $titleOnly = false ) { |
| 74 | + public function isReviewable() { |
75 | 75 | if ( !FlaggedRevs::inReviewNamespace( $this->getTitle() ) ) { |
76 | 76 | return false; |
77 | | - } elseif ( !$titleOnly && FlaggedRevs::forDefaultVersionOnly() |
78 | | - && !$this->isStableShownByDefault() ) |
79 | | - { |
80 | | - return false; |
81 | 77 | } |
82 | | - return true; |
| 78 | + return !( FlaggedRevs::forDefaultVersionOnly() && !$this->isStableShownByDefault() ); |
83 | 79 | } |
84 | 80 | |
85 | 81 | /** |
86 | 82 | * Is this page in patrolable? |
87 | | - * @param bool $titleOnly, only check if title is in reviewable namespace |
88 | 83 | * @return bool |
89 | 84 | */ |
90 | | - public function isPatrollable( $titleOnly = false ) { |
91 | | - if ( FlaggedRevs::inPatrolNamespace( $this->getTitle() ) ) { |
92 | | - return true; |
93 | | - } elseif ( !$titleOnly && FlaggedRevs::forDefaultVersionOnly() |
94 | | - && !$this->isStableShownByDefault() ) |
95 | | - { |
96 | | - return true; |
97 | | - } |
98 | | - return false; |
| 85 | + public function isPatrollable() { |
| 86 | + if ( !FlaggedRevs::inPatrolNamespace( $this->getTitle() ) ) { |
| 87 | + return false; |
| 88 | + } |
| 89 | + return !$this->isReviewable(); // pages that are reviewable are not patrollable |
99 | 90 | } |
100 | 91 | |
101 | 92 | /** |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | self::$restrictionLevels = array( '' ) + self::$restrictionLevels; |
100 | 100 | } |
101 | 101 | # Make sure no talk namespaces are in review namespace |
102 | | - global $wgFlaggedRevsNamespaces; |
| 102 | + global $wgFlaggedRevsNamespaces, $wgFlaggedRevsPatrolNamespaces; |
103 | 103 | foreach ( $wgFlaggedRevsNamespaces as $ns ) { |
104 | 104 | if ( MWNamespace::isTalk( $ns ) ) { |
105 | 105 | throw new MWException( 'FlaggedRevs given talk namespace in $wgFlaggedRevsNamespaces!' ); |
— | — | @@ -107,11 +107,8 @@ |
108 | 108 | } |
109 | 109 | } |
110 | 110 | self::$reviewNamespaces = $wgFlaggedRevsNamespaces; |
111 | | - # Reviewable namespaces override patrolable ones |
112 | | - global $wgFlaggedRevsPatrolNamespaces; |
113 | | - self::$patrolNamespaces = array_diff( |
114 | | - $wgFlaggedRevsPatrolNamespaces, $wgFlaggedRevsNamespaces |
115 | | - ); |
| 111 | + # Note: reviewable *pages* override patrollable ones |
| 112 | + self::$patrolNamespaces = $wgFlaggedRevsPatrolNamespaces; |
116 | 113 | |
117 | 114 | self::$loaded = true; |
118 | 115 | } |
— | — | @@ -1107,12 +1104,13 @@ |
1108 | 1105 | /** |
1109 | 1106 | * @param int $page_id |
1110 | 1107 | * @param int $rev_id |
1111 | | - * @param $flags, GAID_FOR_UPDATE |
| 1108 | + * @param $flags, FR_MASTER |
1112 | 1109 | * @returns mixed (int or false) |
1113 | 1110 | * Get quality of a revision |
1114 | 1111 | */ |
1115 | 1112 | public static function getRevQuality( $page_id, $rev_id, $flags = 0 ) { |
1116 | | - $db = ( $flags & GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
| 1113 | + $db = ( $flags & FR_MASTER ) ? |
| 1114 | + wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
1117 | 1115 | return $db->selectField( 'flaggedrevs', |
1118 | 1116 | 'fr_quality', |
1119 | 1117 | array( 'fr_page_id' => $page_id, 'fr_rev_id' => $rev_id ), |
— | — | @@ -1124,7 +1122,7 @@ |
1125 | 1123 | /** |
1126 | 1124 | * @param Title $title |
1127 | 1125 | * @param int $rev_id |
1128 | | - * @param $flags, GAID_FOR_UPDATE |
| 1126 | + * @param $flags, FR_MASTER |
1129 | 1127 | * @returns bool |
1130 | 1128 | * Useful for quickly pinging to see if a revision is flagged |
1131 | 1129 | */ |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | } |
47 | 47 | $fa = FlaggedArticleView::globalArticleInstance(); |
48 | 48 | # Try to only add to relevant pages |
49 | | - if ( !$fa || !$fa->isReviewable( true ) ) { |
| 49 | + if ( !$fa || !$fa->isReviewable() ) { |
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | global $wgScriptPath, $wgJsMimeType, $wgFlaggedRevsStylePath, $wgFlaggedRevStyleVersion; |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | global $wgUser; |
80 | 80 | $fa = FlaggedArticleView::globalArticleInstance(); |
81 | 81 | # Try to only add to relevant pages |
82 | | - if ( !$fa || !$fa->isReviewable( true ) ) { |
| 82 | + if ( !$fa || !FlaggedRevs::inReviewNamespace( $fa->getTitle() ) ) { |
83 | 83 | return true; |
84 | 84 | } |
85 | 85 | # Get the review tags on this wiki |
— | — | @@ -773,8 +773,9 @@ |
774 | 774 | } |
775 | 775 | # Don't let users vandalize pages by moving them... |
776 | 776 | if ( $action === 'move' ) { |
777 | | - if ( !FlaggedRevs::inReviewNamespace( $title ) || !$title->exists() ) |
| 777 | + if ( !FlaggedRevs::inReviewNamespace( $title ) || !$title->exists() ) { |
778 | 778 | return true; |
| 779 | + } |
779 | 780 | $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
780 | 781 | # If the current shows be default anyway, nothing to do... |
781 | 782 | if ( !$flaggedArticle->isStableShownByDefault() ) { |
— | — | @@ -788,28 +789,15 @@ |
789 | 790 | } |
790 | 791 | # Don't let users patrol pages not in $wgFlaggedRevsPatrolNamespaces |
791 | 792 | } else if ( $action === 'patrol' || $action === 'autopatrol' ) { |
792 | | - # Pages in reviewable namespace can be patrolled IF reviewing |
793 | | - # is disabled for pages that don't show the stable by default. |
794 | | - # In such cases, we let people with 'review' rights patrol them. |
795 | | - if ( FlaggedRevs::inReviewNamespace( $title ) && !$user->isAllowed( 'review' ) ) { |
| 793 | + $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
| 794 | + # For a page to be patrollable it must not be reviewable. |
| 795 | + # Note: normally, edits to non-reviewable, non-patrollable, pages are |
| 796 | + # silently marked patrolled automatically. With $wgUseNPPatrol on, the |
| 797 | + # first edit to those pages is left as being unpatrolled. |
| 798 | + if ( $flaggedArticle->isReviewable() ) { |
796 | 799 | $result = false; |
797 | 800 | return false; |
798 | 801 | } |
799 | | - $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
800 | | - # The page must be in a patrollable namespace ($wgFlaggedRevsPatrolNamespaces)... |
801 | | - if ( !$flaggedArticle->isPatrollable() ) { |
802 | | - global $wgUseNPPatrol; |
803 | | - # ...unless the page is not in a reviewable namespace and |
804 | | - # new page patrol is enabled. In this scenario, any edits |
805 | | - # to pages outside of patrollable namespaces would already |
806 | | - # be auto-patrolled, except for the new page edits. |
807 | | - if ( $wgUseNPPatrol && !$flaggedArticle->isReviewable() ) { |
808 | | - return true; |
809 | | - } else { |
810 | | - $result = false; |
811 | | - return false; |
812 | | - } |
813 | | - } |
814 | 802 | # Enforce autoreview restrictions |
815 | 803 | } else if( $action === 'autoreview' ) { |
816 | 804 | # Get autoreview restriction settings... |
— | — | @@ -1046,15 +1034,13 @@ |
1047 | 1035 | if ( empty( $rc->mAttribs['rc_this_oldid'] ) ) { |
1048 | 1036 | return true; |
1049 | 1037 | } |
| 1038 | + $fa = FlaggedArticle::getTitleInstance( $rc->getTitle() ); |
1050 | 1039 | // Is the page reviewable? |
1051 | | - if ( FlaggedRevs::inReviewNamespace( $rc->getTitle() ) ) { |
1052 | | - # Note: pages in reviewable namespace with FR disabled |
1053 | | - # won't autopatrol. May or may not be useful... |
1054 | | - $quality = FlaggedRevs::getRevQuality( $rc->mAttribs['rc_cur_id'], |
1055 | | - $rc->mAttribs['rc_this_oldid'], GAID_FOR_UPDATE ); |
| 1040 | + if ( $fa->isReviewable() ) { |
| 1041 | + $revId = $rc->mAttribs['rc_this_oldid']; |
| 1042 | + $quality = FlaggedRevs::getRevQuality( $rc->mAttribs['rc_cur_id'], $revId, FR_MASTER ); |
1056 | 1043 | if ( $quality !== false && $quality >= FlaggedRevs::getPatrolLevel() ) { |
1057 | | - RevisionReview::updateRecentChanges( $rc->getTitle(), |
1058 | | - $rc->mAttribs['rc_this_oldid'] ); |
| 1044 | + RevisionReview::updateRecentChanges( $rc->getTitle(), $revId ); |
1059 | 1045 | $rc->mAttribs['rc_patrolled'] = 1; // make sure irc/email notifs know status |
1060 | 1046 | } |
1061 | 1047 | return true; |
— | — | @@ -1062,21 +1048,22 @@ |
1063 | 1049 | // Is this page in patrollable namespace? |
1064 | 1050 | $patrol = $record = false; |
1065 | 1051 | if ( FlaggedRevs::inPatrolNamespace( $rc->getTitle() ) ) { |
1066 | | - # Bots and users with 'autopatrol' have edits to patrolleable pages |
1067 | | - # marked automatically on edit. |
| 1052 | + # Bots and users with 'autopatrol' have edits to patrollable |
| 1053 | + # pages marked automatically on edit. |
1068 | 1054 | $patrol = $wgUser->isAllowed( 'autopatrol' ) || $wgUser->isAllowed( 'bot' ); |
1069 | | - $record = true; |
| 1055 | + $record = true; // record if patrolled |
1070 | 1056 | } else { |
1071 | 1057 | global $wgUseNPPatrol; |
1072 | | - # Mark patrolled by default unless this is a new page and new page patrol |
1073 | | - # is enabled (except when the user has 'autopatrol', then patrol it). |
1074 | | - # This is just to avoid RC clutter for non-patrollable pages. |
1075 | | - if ( $wgUser->isAllowed( 'autopatrol' ) ) { |
1076 | | - $patrol = true; |
1077 | | - # Record patrolled new pages if $wgUseNPPatrol is on |
1078 | | - $record = ( $wgUseNPPatrol && !empty( $rc->mAttribs['rc_new'] ) ); |
| 1058 | + // Is this is a new page edit and $wgUseNPPatrol is enabled? |
| 1059 | + if( $wgUseNPPatrol && !empty( $rc->mAttribs['rc_new'] ) ) { |
| 1060 | + # Automatically mark it patrolled if the user can do so |
| 1061 | + $patrol = $wgUser->isAllowed( 'autopatrol' ); |
| 1062 | + $record = true; |
| 1063 | + // Otherwise, this edit is not patrollable |
1079 | 1064 | } else { |
1080 | | - $patrol = !( $wgUseNPPatrol && !empty( $rc->mAttribs['rc_new'] ) ); |
| 1065 | + # Silently mark it "patrolled" so that it doesn't show up as being unpatrolled |
| 1066 | + $patrol = true; |
| 1067 | + $record = false; |
1081 | 1068 | } |
1082 | 1069 | } |
1083 | 1070 | // Set rc_patrolled flag and add log entry as needed |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -122,8 +122,8 @@ |
123 | 123 | public function displayTag() { |
124 | 124 | global $wgOut, $wgRequest; |
125 | 125 | $this->load(); |
126 | | - // Sanity check that this is in reviewable namespace |
127 | | - if ( $this->article->isReviewable( true ) ) { |
| 126 | + // Sanity check that this is a reviewable page |
| 127 | + if ( $this->article->isReviewable() ) { |
128 | 128 | $wgOut->appendSubtitle( $this->reviewNotice ); |
129 | 129 | } |
130 | 130 | return true; |
— | — | @@ -945,7 +945,7 @@ |
946 | 946 | if ( FlaggedRevs::getProtectionLevels() ) |
947 | 947 | return true; // simple custom levels set for action=protect |
948 | 948 | # Check only if the title is reviewable |
949 | | - if ( !$this->article->isReviewable( true ) ) { |
| 949 | + if ( !FlaggedRevs::inReviewNamespace( $this->article->getTitle() ) ) { |
950 | 950 | return true; |
951 | 951 | } |
952 | 952 | $action = $wgRequest->getVal( 'action', 'view' ); |