Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | private $mRevId; |
27 | 27 | |
28 | 28 | /** |
29 | | - * @param Row $row (from database) |
| 29 | + * @param mixed $row (DB row or array) |
30 | 30 | */ |
31 | 31 | public function __construct( $row ) { |
32 | 32 | if ( is_object( $row ) ) { |
— | — | @@ -69,11 +69,12 @@ |
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
| 73 | + * Get a FlaggedRevision for a title and rev ID. |
| 74 | + * Note: will return NULL if the revision is deleted. |
73 | 75 | * @param Title $title |
74 | 76 | * @param int $revId |
75 | 77 | * @param int $flags |
76 | 78 | * @returns mixed FlaggedRevision (null on failure) |
77 | | - * Will not return a revision if deleted |
78 | 79 | */ |
79 | 80 | public static function newFromTitle( Title $title, $revId, $flags = 0 ) { |
80 | 81 | $columns = self::selectFields(); |
— | — | @@ -116,7 +117,7 @@ |
117 | 118 | } |
118 | 119 | |
119 | 120 | /** |
120 | | - * Get latest quality rev, if not, the latest reviewed one. |
| 121 | + * Get a FlaggedRevision of the stable version of a title. |
121 | 122 | * @param Title $title, page title |
122 | 123 | * @param int $flags |
123 | 124 | * @param array $config, optional page config (use to skip queries) |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -233,7 +233,7 @@ |
234 | 234 | public static function onTitleMoveComplete( &$otitle, &$ntitle, $user, $pageId ) { |
235 | 235 | $fa = FlaggedArticle::getTitleInstance( $ntitle ); |
236 | 236 | // Re-validate NS/config (new title may not be reviewable) |
237 | | - if ( $fa->isReviewable() ) { |
| 237 | + if ( $fa->isReviewable( FR_MASTER ) ) { |
238 | 238 | // Moved from non-reviewable to reviewable NS? |
239 | 239 | if ( FlaggedRevs::autoReviewNewPages() && $user->isAllowed( 'autoreview' ) |
240 | 240 | && !FlaggedRevs::inReviewNamespace( $otitle ) ) |
— | — | @@ -261,8 +261,8 @@ |
262 | 262 | $sv = $u->fr_stableRev; // Try the process cache... |
263 | 263 | } else { |
264 | 264 | $fa = FlaggedArticle::getTitleInstance( $linksUpdate->mTitle ); |
265 | | - if ( $fa->isReviewable() ) { // re-validate NS/config |
266 | | - $sv = $fa->getStableRev( FR_MASTER ); |
| 265 | + if ( FlaggedRevs::inReviewNamespace( $linksUpdate->mTitle ) ) { |
| 266 | + $sv = $fa->getStableRev( FR_MASTER ); // re-validate NS/config |
267 | 267 | } else { |
268 | 268 | $sv = null; |
269 | 269 | } |
— | — | @@ -863,7 +863,7 @@ |
864 | 864 | global $wgRequest; |
865 | 865 | # Edit must be non-null, and to a reviewable page |
866 | 866 | $fa = FlaggedArticle::getArticleInstance( $article ); |
867 | | - if ( !$rev || !$fa->isReviewable() ) { |
| 867 | + if ( !$rev || !$fa->isReviewable( FR_MASTER ) ) { |
868 | 868 | return true; |
869 | 869 | } |
870 | 870 | if ( !$user ) { |
— | — | @@ -1036,7 +1036,7 @@ |
1037 | 1037 | } |
1038 | 1038 | $fa = FlaggedArticle::getTitleInstance( $rc->getTitle() ); |
1039 | 1039 | // Is the page reviewable? |
1040 | | - if ( $fa->isReviewable() ) { |
| 1040 | + if ( $fa->isReviewable( FR_MASTER ) ) { |
1041 | 1041 | $revId = $rc->mAttribs['rc_this_oldid']; |
1042 | 1042 | $quality = FlaggedRevs::getRevQuality( $rc->mAttribs['rc_cur_id'], $revId, FR_MASTER ); |
1043 | 1043 | if ( $quality !== false && $quality >= FlaggedRevs::getPatrolLevel() ) { |
— | — | @@ -1996,7 +1996,7 @@ |
1997 | 1997 | return false; // final |
1998 | 1998 | } |
1999 | 1999 | |
2000 | | - // Add radio of review "protection" options |
| 2000 | + // Add selector of review "protection" options |
2001 | 2001 | // Code stolen from Stabilization (which was stolen from ProtectionForm) |
2002 | 2002 | public static function onProtectionForm( $article, &$output ) { |
2003 | 2003 | global $wgUser, $wgRequest, $wgOut, $wgLang; |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -33,11 +33,12 @@ |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Is the stable version shown by default for this page? |
| 37 | + * @param int $flags, FR_MASTER |
37 | 38 | * @returns bool |
38 | 39 | */ |
39 | | - public function isStableShownByDefault() { |
| 40 | + public function isStableShownByDefault( $flags = 0 ) { |
40 | 41 | # Get page configuration |
41 | | - $config = $this->getVisibilitySettings(); |
| 42 | + $config = $this->getVisibilitySettings( $flags ); |
42 | 43 | return (bool)$config['override']; |
43 | 44 | } |
44 | 45 | |
— | — | @@ -68,24 +69,27 @@ |
69 | 70 | |
70 | 71 | /** |
71 | 72 | * Is this article reviewable? |
| 73 | + * @param int $flags, FR_MASTER |
72 | 74 | * @returns bool |
73 | 75 | */ |
74 | | - public function isReviewable() { |
| 76 | + public function isReviewable( $flags = 0 ) { |
75 | 77 | if ( !FlaggedRevs::inReviewNamespace( $this->getTitle() ) ) { |
76 | 78 | return false; |
77 | 79 | } |
78 | | - return !( FlaggedRevs::forDefaultVersionOnly() && !$this->isStableShownByDefault() ); |
| 80 | + return !( FlaggedRevs::forDefaultVersionOnly() |
| 81 | + && !$this->isStableShownByDefault( $flags ) ); |
79 | 82 | } |
80 | 83 | |
81 | 84 | /** |
82 | 85 | * Is this page in patrolable? |
| 86 | + * @param int $flags, FR_MASTER |
83 | 87 | * @return bool |
84 | 88 | */ |
85 | | - public function isPatrollable() { |
| 89 | + public function isPatrollable( $flags = 0 ) { |
86 | 90 | if ( !FlaggedRevs::inPatrolNamespace( $this->getTitle() ) ) { |
87 | 91 | return false; |
88 | 92 | } |
89 | | - return !$this->isReviewable(); // pages that are reviewable are not patrollable |
| 93 | + return !$this->isReviewable( $flags ); // pages that are reviewable are not patrollable |
90 | 94 | } |
91 | 95 | |
92 | 96 | /** |
— | — | @@ -115,38 +119,18 @@ |
116 | 120 | |
117 | 121 | /** |
118 | 122 | * Get visiblity restrictions on page |
119 | | - * @param Bool $forUpdate, use DB master? |
| 123 | + * @param int $flags, FR_MASTER |
120 | 124 | * @returns Array (select,override) |
121 | | - */ |
122 | | - public function getVisibilitySettings( $forUpdate = false ) { |
| 125 | + */ |
| 126 | + public function getVisibilitySettings( $flags = 0 ) { |
123 | 127 | # Cached results available? |
124 | 128 | if ( !is_null( $this->pageConfig ) ) { |
125 | 129 | return $this->pageConfig; |
126 | 130 | } |
127 | 131 | # Get the content page, skip talk |
128 | 132 | $title = $this->getTitle()->getSubjectPage(); |
129 | | - $config = FlaggedRevs::getPageVisibilitySettings( $title, $forUpdate ); |
| 133 | + $config = FlaggedRevs::getPageVisibilitySettings( $title, $flags ); |
130 | 134 | $this->pageConfig = $config; |
131 | 135 | return $config; |
132 | 136 | } |
133 | | - |
134 | | - /** |
135 | | - * @param int $revId |
136 | | - * @returns Array, output of the flags for a given revision |
137 | | - */ |
138 | | - public function getFlagsForRevision( $revId ) { |
139 | | - # Cached results? |
140 | | - if ( isset( $this->flags[$revId] ) ) { |
141 | | - return $this->flags[$revId]; |
142 | | - } |
143 | | - # Get the flags |
144 | | - $flags = FlaggedRevs::getRevisionTags( $this->getTitle(), $revId ); |
145 | | - # Don't let cache get too big |
146 | | - if ( count( $this->flags ) >= self::CACHE_MAX ) { |
147 | | - $this->flags = array(); |
148 | | - } |
149 | | - # Try to cache results |
150 | | - $this->flags[$revId] = $flags; |
151 | | - return $flags; |
152 | | - } |
153 | 137 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -1181,11 +1181,12 @@ |
1182 | 1182 | /** |
1183 | 1183 | * Get visibility restrictions on page |
1184 | 1184 | * @param Title $title, page title |
1185 | | - * @param bool $forUpdate, use master DB? |
| 1185 | + * @param int $flags, FR_MASTER |
1186 | 1186 | * @returns Array (select,override) |
1187 | 1187 | */ |
1188 | | - public static function getPageVisibilitySettings( $title, $forUpdate = false ) { |
1189 | | - $db = wfGetDB( $forUpdate ? DB_MASTER : DB_SLAVE ); |
| 1188 | + public static function getPageVisibilitySettings( $title, $flags = 0 ) { |
| 1189 | + $db = ($flags & FR_MASTER) ? |
| 1190 | + wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
1190 | 1191 | $row = $db->selectRow( 'flaggedpage_config', |
1191 | 1192 | array( 'fpc_select', 'fpc_override', 'fpc_level', 'fpc_expiry' ), |
1192 | 1193 | array( 'fpc_page_id' => $title->getArticleID() ), |