Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedPage.php |
— | — | @@ -342,14 +342,14 @@ |
343 | 343 | 'fr_rev_id', |
344 | 344 | array( |
345 | 345 | 'fr_page_id' => $this->getId(), |
346 | | - 'rev_page = fr_page_id', |
| 346 | + 'rev_page = fr_page_id', // sanity |
347 | 347 | 'rev_id = fr_rev_id', |
348 | 348 | 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
349 | 349 | ), |
350 | 350 | __METHOD__, |
351 | 351 | array( |
352 | | - 'ORDER BY' => 'fr_quality DESC, fr_rev_id DESC', |
353 | | - 'USE INDEX' => array( 'flaggedrevs' => 'page_qal_rev', 'revision' => 'PRIMARY' ) |
| 352 | + 'ORDER BY' => 'fr_quality DESC, fr_rev_timestamp DESC', |
| 353 | + 'USE INDEX' => array( 'flaggedrevs' => 'page_qal_time' ) |
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | return (int)$oldid; |
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevision.php |
— | — | @@ -191,67 +191,67 @@ |
192 | 192 | if ( !$pageId ) { |
193 | 193 | return null; // short-circuit query |
194 | 194 | } |
195 | | - # Get visiblity settings... |
196 | | - if ( empty( $config ) ) { |
197 | | - $config = FlaggedPageConfig::getStabilitySettings( $title, $flags ); |
| 195 | + # Get visiblity settings to see if page is reviewable... |
| 196 | + if ( FlaggedRevs::useOnlyIfProtected() ) { |
| 197 | + if ( empty( $config ) ) { |
| 198 | + $config = FlaggedPageConfig::getStabilitySettings( $title, $flags ); |
| 199 | + } |
| 200 | + if ( !$config['override'] ) { |
| 201 | + return null; // page is not reviewable; no stable version |
| 202 | + } |
198 | 203 | } |
199 | | - if ( !$config['override'] && FlaggedRevs::useOnlyIfProtected() ) { |
200 | | - return null; // page is not reviewable; no stable version |
201 | | - } |
| 204 | + $baseConds = array( |
| 205 | + 'fr_page_id' => $pageId, |
| 206 | + 'rev_id = fr_rev_id', |
| 207 | + 'rev_page = fr_page_id', // sanity |
| 208 | + 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
| 209 | + ); |
| 210 | + $options['ORDER BY'] = 'fr_rev_timestamp DESC'; |
| 211 | + |
202 | 212 | $row = null; |
203 | | - $options['ORDER BY'] = 'fr_rev_id DESC'; |
204 | | - # Look for the latest pristine revision... |
205 | | - if ( FlaggedRevs::pristineVersions() && $precedence !== 'latest' ) { |
206 | | - $prow = $db->selectRow( |
207 | | - array( 'flaggedrevs', 'revision' ), |
208 | | - self::selectFields(), |
209 | | - array( 'fr_page_id' => $pageId, |
210 | | - 'fr_quality = ' . FR_PRISTINE, |
211 | | - 'rev_id = fr_rev_id', |
212 | | - 'rev_page = fr_page_id', |
213 | | - 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
214 | | - ), |
215 | | - __METHOD__, |
216 | | - $options |
217 | | - ); |
218 | | - # Looks like a plausible revision |
219 | | - $row = $prow ? $prow : $row; |
| 213 | + if ( $precedence !== 'latest' ) { |
| 214 | + # Look for the latest pristine revision... |
| 215 | + if ( FlaggedRevs::pristineVersions() ) { |
| 216 | + $prow = $db->selectRow( |
| 217 | + array( 'flaggedrevs', 'revision' ), |
| 218 | + self::selectFields(), |
| 219 | + array_merge( $baseConds, array( 'fr_quality' => FR_PRISTINE ) ), |
| 220 | + __METHOD__, |
| 221 | + $options |
| 222 | + ); |
| 223 | + # Looks like a plausible revision |
| 224 | + $row = $prow ? $prow : $row; |
| 225 | + } |
| 226 | + if ( $row && $precedence === 'pristine' ) { |
| 227 | + // we have what we want already |
| 228 | + # Look for the latest quality revision... |
| 229 | + } elseif ( FlaggedRevs::qualityVersions() ) { |
| 230 | + // If we found a pristine rev above, this one must be newer... |
| 231 | + $newerClause = $row |
| 232 | + ? array( 'fr_rev_timestamp > '.$db->addQuotes( $row->fr_rev_timestamp ) ) |
| 233 | + : array(); |
| 234 | + $qrow = $db->selectRow( |
| 235 | + array( 'flaggedrevs', 'revision' ), |
| 236 | + self::selectFields(), |
| 237 | + array_merge( $baseConds, array( 'fr_quality' => FR_QUALITY ), $newerClause ), |
| 238 | + __METHOD__, |
| 239 | + $options |
| 240 | + ); |
| 241 | + $row = $qrow ? $qrow : $row; |
| 242 | + } |
220 | 243 | } |
221 | | - if ( $row && $precedence === 'pristine' ) { |
222 | | - // we have what we want already |
223 | | - # Look for the latest quality revision... |
224 | | - } elseif ( FlaggedRevs::qualityVersions() && $precedence !== 'latest' ) { |
225 | | - // If we found a pristine rev above, this one must be newer... |
226 | | - $newerClause = $row ? "fr_rev_id > {$row->fr_rev_id}" : "1 = 1"; |
227 | | - $qrow = $db->selectRow( |
228 | | - array( 'flaggedrevs', 'revision' ), |
229 | | - self::selectFields(), |
230 | | - array( 'fr_page_id' => $pageId, |
231 | | - 'fr_quality = ' . FR_QUALITY, |
232 | | - $newerClause, |
233 | | - 'rev_id = fr_rev_id', |
234 | | - 'rev_page = fr_page_id', |
235 | | - 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
236 | | - ), |
237 | | - __METHOD__, |
238 | | - $options |
239 | | - ); |
240 | | - $row = $qrow ? $qrow : $row; |
241 | | - } |
242 | 244 | # Do we have one? If not, try the latest reviewed revision... |
243 | 245 | if ( !$row ) { |
244 | 246 | $row = $db->selectRow( |
245 | 247 | array( 'flaggedrevs', 'revision' ), |
246 | 248 | self::selectFields(), |
247 | | - array( 'fr_page_id' => $pageId, |
248 | | - 'rev_id = fr_rev_id', |
249 | | - 'rev_page = fr_page_id', |
250 | | - 'rev_deleted & ' . Revision::DELETED_TEXT => 0 |
251 | | - ), |
| 249 | + $baseConds, |
252 | 250 | __METHOD__, |
253 | 251 | $options |
254 | 252 | ); |
255 | | - if ( !$row ) return null; |
| 253 | + if ( !$row ) { |
| 254 | + return null; |
| 255 | + } |
256 | 256 | } |
257 | 257 | $frev = new self( $row ); |
258 | 258 | $frev->mTitle = $title; |
— | — | @@ -309,7 +309,7 @@ |
310 | 310 | ); |
311 | 311 | # Update flagged revisions table |
312 | 312 | $dbw->replace( 'flaggedrevs', |
313 | | - array( array( 'fr_page_id', 'fr_rev_id' ) ), $revRow, __METHOD__ ); |
| 313 | + array( array( 'fr_rev_id' ) ), $revRow, __METHOD__ ); |
314 | 314 | # Clear out any previous garbage... |
315 | 315 | $dbw->delete( 'flaggedtemplates', |
316 | 316 | array( 'ft_rev_id' => $this->getRevId() ), __METHOD__ ); |
— | — | @@ -353,8 +353,9 @@ |
354 | 354 | public static function selectFields() { |
355 | 355 | return array_merge( |
356 | 356 | Revision::selectFields(), |
357 | | - array( 'fr_rev_id', 'fr_page_id', 'fr_user', 'fr_timestamp', 'fr_quality', |
358 | | - 'fr_tags', 'fr_flags', 'fr_img_name', 'fr_img_sha1', 'fr_img_timestamp' ) |
| 357 | + array( 'fr_rev_id', 'fr_page_id', 'fr_rev_timestamp', |
| 358 | + 'fr_user', 'fr_timestamp', 'fr_quality', 'fr_tags', 'fr_flags', |
| 359 | + 'fr_img_name', 'fr_img_sha1', 'fr_img_timestamp' ) |
359 | 360 | ); |
360 | 361 | } |
361 | 362 | |