Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | $wgExtensionCredits['specialpage'][] = array( |
16 | 16 | 'name' => 'Flagged Revisions', |
17 | 17 | 'author' => array( 'Aaron Schulz', 'Joerg Baach' ), |
18 | | - 'version' => '1.042', |
| 18 | + 'version' => '1.041', |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:FlaggedRevs', |
20 | 20 | 'descriptionmsg' => 'flaggedrevs-desc', |
21 | 21 | ); |
— | — | @@ -223,7 +223,7 @@ |
224 | 224 | global $wgOut, $wgHooks, $wgLang, $wgFlaggedArticle, $wgUseRCPatrol; |
225 | 225 | # Initialize |
226 | 226 | FlaggedRevs::load(); |
227 | | - $wgFlaggedArticle = null; |
| 227 | + $wgFlaggedArticle = new FlaggedArticle(); |
228 | 228 | |
229 | 229 | wfLoadExtensionMessages( 'FlaggedRevsPage' ); |
230 | 230 | |
— | — | @@ -238,8 +238,28 @@ |
239 | 239 | define( 'FLAGGED_JS', $wgScriptPath . '/extensions/FlaggedRevs/flaggedrevs.js?' . $wgFlaggedRevStyleVersion ); |
240 | 240 | |
241 | 241 | ######### Hook attachments ######### |
242 | | - # Set $wgFlaggedArticle |
243 | | - $wgHooks['ArticleFromTitle'][] = 'wfInitFlaggedArticle'; |
| 242 | + $wgHooks['OutputPageParserOutput'][] = 'FlaggedRevs::InjectStyleAndJS'; |
| 243 | + $wgHooks['EditPage::showEditForm:initial'][] = 'FlaggedRevs::InjectStyleAndJS'; |
| 244 | + $wgHooks['PageHistoryBeforeList'][] = 'FlaggedRevs::InjectStyleAndJS'; |
| 245 | + # Main hooks, overrides pages content, adds tags, sets tabs and permalink |
| 246 | + $wgHooks['SkinTemplateTabs'][] = array( $wgFlaggedArticle, 'setActionTabs' ); |
| 247 | + # Change last-modified footer |
| 248 | + $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( $wgFlaggedArticle, 'setLastModified' ); |
| 249 | + # Update older, incomplete, page caches (ones that lack template Ids/image timestamps) |
| 250 | + $wgHooks['ArticleViewHeader'][] = array( $wgFlaggedArticle, 'maybeUpdateMainCache' ); |
| 251 | + $wgHooks['ArticleViewHeader'][] = array( $wgFlaggedArticle, 'setPageContent' ); |
| 252 | + $wgHooks['ArticleViewHeader'][] = array( $wgFlaggedArticle, 'addPatrolLink' ); |
| 253 | + # Set image version |
| 254 | + $wgHooks['ArticleFromTitle'][] = array( $wgFlaggedArticle, 'setImageVersion' ); |
| 255 | + # Add page notice |
| 256 | + $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = array( $wgFlaggedArticle, 'setPermaLink' ); |
| 257 | + # Add tags do edit view |
| 258 | + $wgHooks['EditPage::showEditForm:initial'][] = array( $wgFlaggedArticle, 'addToEditView' ); |
| 259 | + # Add review form |
| 260 | + $wgHooks['BeforePageDisplay'][] = array( $wgFlaggedArticle, 'addReviewForm' ); |
| 261 | + $wgHooks['BeforePageDisplay'][] = array( $wgFlaggedArticle, 'addVisibilityLink' ); |
| 262 | + # Mark of items in page history |
| 263 | + $wgHooks['PageHistoryLineEnding'][] = array( $wgFlaggedArticle, 'addToHistLine' ); |
244 | 264 | # Autopromote Editors |
245 | 265 | $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevs::autoPromoteUser'; |
246 | 266 | # Adds table link references to include ones from the stable version |
— | — | @@ -261,10 +281,17 @@ |
262 | 282 | # Additional parser versioning |
263 | 283 | $wgHooks['ParserAfterTidy'][] = 'FlaggedRevs::parserInjectTimestamps'; |
264 | 284 | $wgHooks['OutputPageParserOutput'][] = 'FlaggedRevs::outputInjectTimestamps'; |
265 | | - # Auto-reviewing |
| 285 | + # Page review on edit |
| 286 | + $wgHooks['ArticleUpdateBeforeRedirect'][] = array( $wgFlaggedArticle, 'injectReviewDiffURLParams' ); |
| 287 | + $wgHooks['DiffViewHeader'][] = array( $wgFlaggedArticle, 'addPatrolAndDiffLink' ); |
| 288 | + $wgHooks['DiffViewHeader'][] = array( $wgFlaggedArticle, 'addDiffNoticeAndIncludes' ); |
| 289 | + # Autoreview stuff |
| 290 | + $wgHooks['EditPage::showEditForm:fields'][] = array( $wgFlaggedArticle, 'addRevisionIDField' ); |
| 291 | + $wgHooks['ArticleInsertComplete'][] = array( $wgFlaggedArticle, 'maybeMakeNewPageReviewed' ); |
| 292 | + $wgHooks['ArticleSaveComplete'][] = array( $wgFlaggedArticle, 'maybeMakeEditReviewed' ); |
| 293 | + $wgHooks['ArticleRollbackComplete'][] = array( $wgFlaggedArticle, 'maybeMakeRollbackReviewed' ); |
266 | 294 | $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevs::autoMarkPatrolled'; |
267 | | - $wgHooks['RevisionInsertComplete'][] = 'FlaggedRevs::maybeMakeEditReviewed'; |
268 | | - $wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevs::maybeMakeRollbackReviewed'; |
| 295 | + $wgHooks['RevisionInsertComplete'][] = 'FlaggedRevs::maybeMakeNullEditReviewed'; |
269 | 296 | # Disallow moves of stable pages |
270 | 297 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanMove'; |
271 | 298 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanView'; |
— | — | @@ -280,44 +307,6 @@ |
281 | 308 | ######### |
282 | 309 | } |
283 | 310 | |
284 | | -function wfInitFlaggedArticle( $title, $article ) { |
285 | | - global $wgFlaggedArticle, $wgHooks; |
286 | | - if( !FlaggedRevs::isPageReviewable( $title ) ) |
287 | | - return true; |
288 | | - # Initialize and set article hooks |
289 | | - $wgFlaggedArticle = new FlaggedArticle( $title ); |
290 | | - # Main hooks, overrides pages content, adds tags, sets tabs and permalink |
291 | | - $wgHooks['SkinTemplateTabs'][] = array( $wgFlaggedArticle, 'setActionTabs' ); |
292 | | - # Change last-modified footer |
293 | | - $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( $wgFlaggedArticle, 'setLastModified' ); |
294 | | - # Update older, incomplete, page caches (ones that lack template Ids/image timestamps) |
295 | | - $wgHooks['ArticleViewHeader'][] = array( $wgFlaggedArticle, 'maybeUpdateMainCache' ); |
296 | | - $wgHooks['ArticleViewHeader'][] = array( $wgFlaggedArticle, 'setPageContent' ); |
297 | | - $wgHooks['ArticleViewHeader'][] = array( $wgFlaggedArticle, 'addPatrolLink' ); |
298 | | - # Set image version |
299 | | - $wgHooks['ArticleFromTitle'][] = array( $wgFlaggedArticle, 'setImageVersion' ); |
300 | | - # Add page notice |
301 | | - $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = array( $wgFlaggedArticle, 'setPermaLink' ); |
302 | | - # Add tags do edit view |
303 | | - $wgHooks['EditPage::showEditForm:initial'][] = array( $wgFlaggedArticle, 'addToEditView' ); |
304 | | - # Add review form |
305 | | - $wgHooks['BeforePageDisplay'][] = array( $wgFlaggedArticle, 'addReviewForm' ); |
306 | | - $wgHooks['BeforePageDisplay'][] = array( $wgFlaggedArticle, 'addVisibilityLink' ); |
307 | | - # Mark of items in page history |
308 | | - $wgHooks['PageHistoryLineEnding'][] = array( $wgFlaggedArticle, 'addToHistLine' ); |
309 | | - # Page review on edit |
310 | | - $wgHooks['ArticleUpdateBeforeRedirect'][] = array( $wgFlaggedArticle, 'injectReviewDiffURLParams' ); |
311 | | - $wgHooks['DiffViewHeader'][] = array( $wgFlaggedArticle, 'addPatrolAndDiffLink' ); |
312 | | - $wgHooks['DiffViewHeader'][] = array( $wgFlaggedArticle, 'addDiffNoticeAndIncludes' ); |
313 | | - # Autoreview stuff |
314 | | - $wgHooks['EditPage::showEditForm:fields'][] = array( $wgFlaggedArticle, 'addRevisionIDField' ); |
315 | | - # Add CSS/JS |
316 | | - $wgHooks['OutputPageParserOutput'][] = 'FlaggedRevs::InjectStyleAndJS'; |
317 | | - $wgHooks['EditPage::showEditForm:initial'][] = 'FlaggedRevs::InjectStyleAndJS'; |
318 | | - $wgHooks['PageHistoryBeforeList'][] = 'FlaggedRevs::InjectStyleAndJS'; |
319 | | - return true; |
320 | | -} |
321 | | - |
322 | 311 | # Add review log and such |
323 | 312 | $wgLogTypes[] = 'review'; |
324 | 313 | $wgLogNames['review'] = 'review-logpage'; |
— | — | @@ -337,6 +326,25 @@ |
338 | 327 | |
339 | 328 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'efFlaggedRevsSchemaUpdates'; |
340 | 329 | |
| 330 | +function efFlaggedRevsSchemaUpdates() { |
| 331 | + global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables; |
| 332 | + |
| 333 | + $base = dirname(__FILE__); |
| 334 | + if( $wgDBtype == 'mysql' ) { |
| 335 | + $wgExtNewFields[] = array( 'flaggedpage_config', 'fpc_expiry', "$base/archives/patch-fpc_expiry.sql" ); |
| 336 | + $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/archives/patch-expiry-index.sql" ); |
| 337 | + $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/archives/patch-flaggedrevs_promote.sql" ); |
| 338 | + $wgExtNewTables[] = array( 'flaggedpages', "$base/archives/patch-flaggedpages.sql" ); |
| 339 | + } else if( $wgDBtype == 'postgres' ) { |
| 340 | + $wgExtPGNewFields[] = array('flaggedpage_config', 'fpc_expiry', "TIMESTAMPTZ NULL" ); |
| 341 | + $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/postgres/patch-expiry-index.sql" ); |
| 342 | + $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/postgres/patch-flaggedrevs_promote.sql" ); |
| 343 | + $wgExtNewTables[] = array( 'flaggedpages', "$base/postgres/patch-flaggedpages.sql" ); |
| 344 | + } |
| 345 | + |
| 346 | + return true; |
| 347 | +} |
| 348 | + |
341 | 349 | class FlaggedRevs { |
342 | 350 | public static $dimensions = array(); |
343 | 351 | public static $styleLoaded = false; |
— | — | @@ -426,14 +434,14 @@ |
427 | 435 | */ |
428 | 436 | public static function parseStableText( $article, $text='', $id, $reparsed = true ) { |
429 | 437 | global $wgParser; |
430 | | - $title = $article->getTitle(); // avoid pass-by-reference error |
431 | 438 | # Make our hooks to trigger |
432 | 439 | $wgParser->fr_isStable = true; |
433 | 440 | $wgParser->fr_includesMatched = true; |
434 | 441 | # Don't show section-edit links, they can be old and misleading |
435 | 442 | $options = self::makeParserOptions(); |
436 | | - $options->setEditSection( $id == $title->getLatestRevID(GAID_FOR_UPDATE) ); |
| 443 | + $options->setEditSection( $id==$article->getLatest() ); |
437 | 444 | # Parse the new body, wikitext -> html |
| 445 | + $title = $article->getTitle(); // avoid pass-by-reference error |
438 | 446 | $parserOut = $wgParser->parse( $text, $title, $options, true, true, $id ); |
439 | 447 | $parserOut->fr_includesMatched = $wgParser->fr_includesMatched; |
440 | 448 | # Done with parser! |
— | — | @@ -482,14 +490,14 @@ |
483 | 491 | /** |
484 | 492 | * @param FlaggedRevision $frev |
485 | 493 | * @param Article $article |
486 | | - * @param ParserOutput $stableOutput, will fetch if not given |
| 494 | + * @param ParserOutput $flaggedOutput, will fetch if not given |
487 | 495 | * @param ParserOutput $currentOutput, will fetch if not given |
488 | 496 | * @return bool |
489 | 497 | * See if a flagged revision is synced with the current |
490 | 498 | */ |
491 | | - public static function flaggedRevIsSynced( $frev, $article, $stableOutput=null, $currentOutput=null ) { |
| 499 | + public static function flaggedRevIsSynced( $frev, $article, $flaggedOutput=null, $currentOutput=null ) { |
492 | 500 | # Must be the same revision |
493 | | - if( $frev->getRevId() != $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) ) { |
| 501 | + if( $frev->getRevId() != $article->getLatest() ) { |
494 | 502 | return false; |
495 | 503 | } |
496 | 504 | global $wgMemc; |
— | — | @@ -505,14 +513,20 @@ |
506 | 514 | } |
507 | 515 | } |
508 | 516 | # If parseroutputs not given, fetch them... |
509 | | - if( is_null($stableOutput) || !isset($stableOutput->fr_newestTemplateID) ) { |
| 517 | + if( is_null($flaggedOutput) || !isset($flaggedOutput->fr_newestTemplateID) ) { |
510 | 518 | # Get parsed stable version |
511 | | - $stableOutput = self::getPageCache( $article ); |
512 | | - if( $stableOutput==false ) { |
513 | | - $text = $frev->getTextForParse(); |
514 | | - $stableOutput = self::parseStableText( $article, $text, $frev->getRevId() ); |
| 519 | + $flaggedOutput = FlaggedRevs::getPageCache( $article ); |
| 520 | + if( $flaggedOutput==false ) { |
| 521 | + global $wgUseStableTemplates; |
| 522 | + if( $wgUseStableTemplates ) { |
| 523 | + $rev = Revision::newFromId( $frev->getRevId() ); |
| 524 | + $text = $rev->getText(); |
| 525 | + } else { |
| 526 | + $text = $frev->getExpandedText(); |
| 527 | + } |
| 528 | + $flaggedOutput = FlaggedRevs::parseStableText( $article, $text, $frev->getRevId() ); |
515 | 529 | # Update the stable version cache |
516 | | - self::updatePageCache( $article, $stableOutput ); |
| 530 | + FlaggedRevs::updatePageCache( $article, $flaggedOutput ); |
517 | 531 | } |
518 | 532 | } |
519 | 533 | if( is_null($currentOutput) || !isset($currentOutput->fr_newestTemplateID) ) { |
— | — | @@ -526,17 +540,15 @@ |
527 | 541 | $options = self::makeParserOptions( $wgUser ); |
528 | 542 | $currentOutput = $wgParser->parse( $text, $title, $options ); |
529 | 543 | # Might as well save the cache while we're at it |
530 | | - global $wgEnableParserCache; |
531 | | - if( $wgEnableParserCache ) |
532 | | - $parserCache->save( $currentOutput, $article, $wgUser ); |
| 544 | + $parserCache->save( $currentOutput, $article, $wgUser ); |
533 | 545 | } |
534 | 546 | } |
535 | 547 | # Only current of revisions of inclusions can be reviewed. Since the stable and current revisions |
536 | 548 | # have the same text, the only thing that can make them different is updating a template or image. |
537 | 549 | # If this is the case, the current revision will have a newer template or image version used somewhere. |
538 | | - if( $currentOutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) { |
| 550 | + if( $currentOutput->fr_newestImageTime > $flaggedOutput->fr_newestImageTime ) { |
539 | 551 | $synced = false; |
540 | | - } else if( $currentOutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) { |
| 552 | + } else if( $currentOutput->fr_newestTemplateID > $flaggedOutput->fr_newestTemplateID ) { |
541 | 553 | $synced = false; |
542 | 554 | } else { |
543 | 555 | $synced = true; |
— | — | @@ -546,7 +558,7 @@ |
547 | 559 | global $wgParserCacheExpireTime; |
548 | 560 | $syncData = $synced ? "true" : "false"; |
549 | 561 | $wgMemc->set( $key, $syncData, $wgParserCacheExpireTime ); |
550 | | - |
| 562 | + |
551 | 563 | return $synced; |
552 | 564 | } |
553 | 565 | |
— | — | @@ -646,6 +658,7 @@ |
647 | 659 | if( $row ) { |
648 | 660 | return new FlaggedRevision( $title, $row ); |
649 | 661 | } |
| 662 | + |
650 | 663 | return null; |
651 | 664 | } |
652 | 665 | |
— | — | @@ -657,13 +670,11 @@ |
658 | 671 | */ |
659 | 672 | public static function getRevQuality( $title, $rev_id, $db = NULL ) { |
660 | 673 | $db = $db ? $db : wfGetDB( DB_SLAVE ); |
661 | | - $quality = $db->selectField( 'flaggedrevs', |
662 | | - 'fr_quality', |
| 674 | + $quality = $db->selectField( 'flaggedrevs', 'fr_quality', |
663 | 675 | array( 'fr_page_id' => $title->getArticleID(), |
664 | 676 | 'fr_rev_id' => $rev_id ), |
665 | 677 | __METHOD__, |
666 | | - array( 'FORCE INDEX' => 'PRIMARY' ) |
667 | | - ); |
| 678 | + array( 'FORCE INDEX' => 'PRIMARY' ) ); |
668 | 679 | return $quality; |
669 | 680 | } |
670 | 681 | |
— | — | @@ -754,7 +765,7 @@ |
755 | 766 | # Check if the count is zero by using $article->getLatest(). |
756 | 767 | # I don't trust using memcache and PHP for values like '0' |
757 | 768 | # as it may confuse "expired" with "0". -aaron |
758 | | - if( $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) == $from_rev ) { |
| 769 | + if( $article->getLatest()==$from_rev ) { |
759 | 770 | return 0; |
760 | 771 | } |
761 | 772 | global $wgMemc; |
— | — | @@ -862,7 +873,7 @@ |
863 | 874 | public static function getRevisionTags( $title, $rev_id ) { |
864 | 875 | $dbr = wfGetDB( DB_SLAVE ); |
865 | 876 | $tags = $dbr->selectField( 'flaggedrevs', 'fr_tags', |
866 | | - array( 'fr_rev_id' => $rev_id, |
| 877 | + array('fr_rev_id' => $rev_id, |
867 | 878 | 'fr_page_id' => $title->getArticleId() ), |
868 | 879 | __METHOD__ ); |
869 | 880 | if( !$tags ) |
— | — | @@ -1034,10 +1045,10 @@ |
1035 | 1046 | /** |
1036 | 1047 | * Add FlaggedRevs css/js. Attached to two different hooks, neglect inputs. |
1037 | 1048 | */ |
1038 | | - public static function InjectStyleAndJS() { |
| 1049 | + public static function InjectStyleAndJS( $a=false, $b=false ) { |
1039 | 1050 | global $wgOut, $wgJsMimeType, $wgFlaggedArticle; |
1040 | 1051 | # Don't double-load |
1041 | | - if( self::$styleLoaded || !$wgFlaggedArticle ) |
| 1052 | + if( self::$styleLoaded ) |
1042 | 1053 | return true; |
1043 | 1054 | # UI CSS |
1044 | 1055 | $wgOut->addLink( array( |
— | — | @@ -1093,18 +1104,19 @@ |
1094 | 1105 | $quality = self::isPristine($flags) ? 2 : 1; |
1095 | 1106 | } |
1096 | 1107 | $tmpset = $imgset = array(); |
1097 | | - $poutput = false; |
1098 | 1108 | # Try the parser cache, should be set on the edit before this is called. |
1099 | 1109 | # If not set or up to date, then parse it. Use master to avoid lag issues. |
| 1110 | + $poutput = false; |
1100 | 1111 | $latestID = $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE); |
1101 | | - if( $poutput == false ) { |
| 1112 | + if( $latestID == $rev->getId() ) { |
| 1113 | + $parserCache = ParserCache::singleton(); |
| 1114 | + $poutput = $parserCache->get( $article, $user ); |
| 1115 | + } |
| 1116 | + if( $poutput==false ) { |
1102 | 1117 | $options = self::makeParserOptions( $user ); |
1103 | | - $title = $article->getTitle(); // avoid pass-by-ref error |
1104 | | - $poutput = $wgParser->parse( $text, $title, $options, true, true, $latestID ); |
| 1118 | + $poutput = $wgParser->parse( $text, $article->getTitle(), $options, true, true, $rev->getId() ); |
1105 | 1119 | # Might as well save the cache while we're at it |
1106 | | - global $wgEnableParserCache; |
1107 | | - if( $wgEnableParserCache && $latestID == $rev->getId() ) { |
1108 | | - $parserCache = ParserCache::singleton(); |
| 1120 | + if( $latestID == $rev->getId() ) { |
1109 | 1121 | $parserCache->save( $poutput, $article, $user ); |
1110 | 1122 | } |
1111 | 1123 | } |
— | — | @@ -1151,7 +1163,7 @@ |
1152 | 1164 | $textFlags = self::compressText( $fulltext ); |
1153 | 1165 | |
1154 | 1166 | # Write to external storage if required |
1155 | | - $storage = self::getExternalStorage(); |
| 1167 | + $storage = FlaggedRevs::getExternalStorage(); |
1156 | 1168 | if( $storage ) { |
1157 | 1169 | if( is_array($storage) ) { |
1158 | 1170 | # Distribute storage across multiple clusters |
— | — | @@ -1207,7 +1219,7 @@ |
1208 | 1220 | $sv = self::getStablePageRev( $article->getTitle(), false, true ); |
1209 | 1221 | if( $sv && $sv->getRevId() == $rev->getId() ) { |
1210 | 1222 | # Update stable cache |
1211 | | - self::updatePageCache( $article, $poutput ); |
| 1223 | + FlaggedRevs::updatePageCache( $article, $poutput ); |
1212 | 1224 | # Update page fields |
1213 | 1225 | self::updateArticleOn( $article, $rev->getId(), $rev->getId() ); |
1214 | 1226 | # Purge squid for this page only |
— | — | @@ -1341,9 +1353,7 @@ |
1342 | 1354 | $options = self::makeParserOptions( $wgUser ); |
1343 | 1355 | $poutput = $wgParser->parse($text, $article->getTitle(), $options); |
1344 | 1356 | # Might as well save the cache while we're at it |
1345 | | - global $wgEnableParserCache; |
1346 | | - if( $wgEnableParserCache ) |
1347 | | - $parserCache->save( $poutput, $article, $wgUser ); |
| 1357 | + $parserCache->save( $poutput, $article, $wgUser ); |
1348 | 1358 | } |
1349 | 1359 | $u = new LinksUpdate( $article->getTitle(), $poutput ); |
1350 | 1360 | $u->doUpdate(); // this will trigger our hook to add stable links too... |
— | — | @@ -1380,7 +1390,12 @@ |
1381 | 1391 | # Try stable version cache. This should be updated before this is called. |
1382 | 1392 | $parserOut = self::getPageCache( $article ); |
1383 | 1393 | if( $parserOut==false ) { |
1384 | | - $text = $sv->getTextForParse(); |
| 1394 | + if( $wgUseStableTemplates ) { |
| 1395 | + $rev = Revision::newFromId( $sv->getRevId() ); |
| 1396 | + $text = $rev->getText(); |
| 1397 | + } else { |
| 1398 | + $text = $sv->getExpandedText(); |
| 1399 | + } |
1385 | 1400 | # Parse the text |
1386 | 1401 | $parserOut = self::parseStableText( $article, $text, $sv->getRevId() ); |
1387 | 1402 | } |
— | — | @@ -1699,12 +1714,13 @@ |
1700 | 1715 | * Don't let users vandalize pages by moving them. |
1701 | 1716 | */ |
1702 | 1717 | public static function userCanMove( $title, $user, $action, $result ) { |
1703 | | - global $wgTitle, $wgFlaggedArticle; |
| 1718 | + global $wgTitle; |
1704 | 1719 | |
1705 | 1720 | if( $action != 'move' || !self::isPageReviewable( $title ) ) |
1706 | 1721 | return true; |
1707 | 1722 | # See if there is a stable version |
1708 | | - if( $wgFlaggedArticle && $wgTitle && $wgTitle->equals( $title ) ) { |
| 1723 | + if( $wgTitle && $wgTitle->equals( $title ) ) { |
| 1724 | + global $wgFlaggedArticle; |
1709 | 1725 | // Cache stable version while we are at it. |
1710 | 1726 | $frev = $wgFlaggedArticle->getStableRev( true ); |
1711 | 1727 | } else { |
— | — | @@ -1725,7 +1741,7 @@ |
1726 | 1742 | * Allow users to view reviewed pages. |
1727 | 1743 | */ |
1728 | 1744 | public static function userCanView( $title, $user, $action, $result ) { |
1729 | | - global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle, $wgFlaggedArticle; |
| 1745 | + global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle; |
1730 | 1746 | # Assume $action may still not be set, in which case, treat it as 'view'... |
1731 | 1747 | if( $action != 'read' ) |
1732 | 1748 | return true; |
— | — | @@ -1741,7 +1757,7 @@ |
1742 | 1758 | } |
1743 | 1759 | # See if there is a stable version. Also, see if, given the page |
1744 | 1760 | # config and URL params, the page can be overriden. |
1745 | | - if( $wgFlaggedArticle && $wgTitle && $wgTitle->equals( $title ) ) { |
| 1761 | + if( $wgTitle && $wgTitle->equals( $title ) ) { |
1746 | 1762 | global $wgFlaggedArticle; |
1747 | 1763 | // Cache stable version while we are at it. |
1748 | 1764 | if( $wgFlaggedArticle->pageOverride() && $wgFlaggedArticle->getStableRev( true ) ) { |
— | — | @@ -1756,89 +1772,42 @@ |
1757 | 1773 | } |
1758 | 1774 | |
1759 | 1775 | /** |
1760 | | - * When an edit is made by a reviewer, if the current revision is the stable |
1761 | | - * version, try to automatically review it. |
| 1776 | + * When a null edit is made, autoreview if necessary |
1762 | 1777 | */ |
1763 | | - public static function maybeMakeEditReviewed( $rev ) { |
1764 | | - global $wgFlaggedRevsAutoReview, $wgFlaggedRevsAutoReviewNew, $wgFlaggedArticle, $wgRequest; |
1765 | | - # Get the user |
1766 | | - $user = User::newFromId( $rev->getUser() ); |
1767 | | - if( !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) |
1768 | | - return true; |
| 1778 | + public static function maybeMakeNullEditReviewed( $rev ) { |
| 1779 | + $title = $rev->getTitle(); |
1769 | 1780 | # GetTitle() for revisions uses slaves and wants page_id,rev_id to |
1770 | 1781 | # match...this is bad if we *just* added it. |
1771 | | - $title = $rev->getTitle() ? $rev->getTitle() : Title::newFromID( $rev->getPage(), GAID_FOR_UPDATE ); |
1772 | | - # Must be in reviewable namespace |
| 1782 | + $title = $title ? $title : Title::newFromID( $rev->getPage() ); |
1773 | 1783 | if( !$title || !self::isPageReviewable( $title ) ) { |
1774 | 1784 | return true; |
1775 | 1785 | } |
1776 | | - $article = new Article( $title ); |
1777 | | - # Revision will be null for null edits |
1778 | | - if( $rev ) { |
1779 | | - $frev = null; |
1780 | | - $reviewableNewPage = false; |
1781 | | - # Get the revision the incoming one was based off |
1782 | | - $baseRevID = $wgRequest->getVal('baseRevId'); |
1783 | | - if( $baseRevID ) { |
1784 | | - $frev = self::getFlaggedRev( $article->getTitle(), $baseRevID ); |
1785 | | - } else { |
1786 | | - $prevRevID = $article->getTitle()->getPreviousRevisionId( $rev->getId() ); |
1787 | | - $prevRev = $prevRevID ? Revision::newFromID( $prevRevID ) : null; |
1788 | | - # Check for null edits |
1789 | | - if( $prevRev && $prevRev->getTextId() == $rev->getTextId() ) { |
1790 | | - $frev = self::getFlaggedRev( $title, $prevRev->getId() ); |
1791 | | - # Check for new pages |
1792 | | - } else if( !$prevRev ) { |
1793 | | - $reviewableNewPage = $wgFlaggedRevsAutoReviewNew; |
| 1786 | + $prevRevID = $title->getPreviousRevisionId( $rev->getId() ); |
| 1787 | + if( !$prevRevID ) |
| 1788 | + return true; |
| 1789 | + $prevRev = Revision::newFromID( $prevRevID ); |
| 1790 | + # Check for null edits |
| 1791 | + if( $prevRev && $prevRev->getTextId() == $rev->getTextId() ) { |
| 1792 | + $frev = FlaggedRevs::getFlaggedRev( $title, $prevRev->getId() ); |
| 1793 | + if( !is_null($frev) ) { |
| 1794 | + $article = new Article( $title ); |
| 1795 | + $flags = $frev->getTags(); |
| 1796 | + # Check if user is allowed to renew the stable version. |
| 1797 | + if( !RevisionReview::userCanSetFlags( $flags ) ) { |
| 1798 | + # Assume basic flagging level |
| 1799 | + $flags = array(); |
| 1800 | + foreach( FlaggedRevs::$dimensions as $tag => $minQL ) { |
| 1801 | + $flags[$tag] = 1; |
| 1802 | + } |
1794 | 1803 | } |
| 1804 | + $user = User::newFromId( $rev->getUser() ); |
| 1805 | + FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags ); |
1795 | 1806 | } |
1796 | | - # Is this an edit directly to the stable version? |
1797 | | - if( $reviewableNewPage || !is_null($frev) ) { |
1798 | | - # Assume basic flagging level |
1799 | | - $flags = array(); |
1800 | | - foreach( self::$dimensions as $tag => $minQL ) { |
1801 | | - $flags[$tag] = 1; |
1802 | | - } |
1803 | | - self::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags ); |
1804 | | - } |
1805 | 1807 | } |
1806 | | - if( $wgFlaggedArticle ) { |
1807 | | - $wgFlaggedArticle->skipReviewDiff = true; // Don't jump to diff... |
1808 | | - } |
1809 | 1808 | return true; |
1810 | 1809 | } |
1811 | 1810 | |
1812 | 1811 | /** |
1813 | | - * When a rollback is made by a reviwer, try to automatically review it. |
1814 | | - */ |
1815 | | - public static function maybeMakeRollbackReviewed( $article, $user, $rev ) { |
1816 | | - global $wgFlaggedRevsAutoReview, $wgFlaggedArticle; |
1817 | | - if( !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) |
1818 | | - return true; |
1819 | | - # Must be in reviewable namespace |
1820 | | - if( !self::isPageReviewable( $article->getTitle() ) ) |
1821 | | - return true; |
1822 | | - # Was this revision flagged? |
1823 | | - $frev = self::getFlaggedRev( $article->getTitle(), $rev->getId() ); |
1824 | | - if( !is_null($frev) ) { |
1825 | | - # Assume basic flagging level |
1826 | | - $flags = array(); |
1827 | | - foreach( self::$dimensions as $tag => $minQL ) { |
1828 | | - $flags[$tag] = 1; |
1829 | | - } |
1830 | | - $newRev = Revision::newFromId( $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) ); |
1831 | | - if( $newRev ) { |
1832 | | - self::autoReviewEdit( $article, $user, $rev->getText(), $newRev, $flags ); |
1833 | | - self::articleLinksUpdate( $article ); // lame... |
1834 | | - } |
1835 | | - } |
1836 | | - if( $wgFlaggedArticle ) { |
1837 | | - $wgFlaggedArticle->skipReviewDiff = true; // Don't jump to diff... |
1838 | | - } |
1839 | | - return true; |
1840 | | - } |
1841 | | - |
1842 | | - /** |
1843 | 1812 | * When an edit is made to a page that can't be reviewed, autopatrol if allowed. |
1844 | 1813 | * This is not loggged for perfomance reasons and no one cares if talk pages and such |
1845 | 1814 | * are autopatrolled. |
— | — | @@ -2145,8 +2114,46 @@ |
2146 | 2115 | * Add user preference to form HTML |
2147 | 2116 | */ |
2148 | 2117 | public static function injectPreferences( $form, $out ) { |
2149 | | - $prefsHtml = FlaggedRevsXML::stabilityPreferences( $form ); |
2150 | | - $out->addHTML( $prefsHtml ); |
| 2118 | + global $wgUser; |
| 2119 | + |
| 2120 | + $out->addHTML( |
| 2121 | + Xml::openElement( 'fieldset' ) . |
| 2122 | + Xml::element( 'legend', null, wfMsgHtml('flaggedrevs-prefs') ) . |
| 2123 | + Xml::openElement( 'table' ) . |
| 2124 | + Xml::openElement( 'tr' ) . |
| 2125 | + '<td>' . wfCheck( 'wpFlaggedRevsStable', $form->mFlaggedRevsStable, |
| 2126 | + array('id' => 'wpFlaggedRevsStable') ) . '</td><td> ' . |
| 2127 | + wfLabel( wfMsg( 'flaggedrevs-prefs-stable' ), 'wpFlaggedRevsStable' ) . '</td>' . |
| 2128 | + Xml::closeElement( 'tr' ) . |
| 2129 | + Xml::openElement( 'tr' ) . |
| 2130 | + '<td>' . |
| 2131 | + Xml::radio( 'wpFlaggedRevsSUI', 0, $form->mFlaggedRevsSUI==0, array('id' => 'standardUI') ) . |
| 2132 | + '</td><td> ' . |
| 2133 | + Xml::label( wfMsgHtml('flaggedrevs-pref-UI-0'), 'standardUI' ) . |
| 2134 | + '</td>' . |
| 2135 | + Xml::closeElement( 'tr' ) . |
| 2136 | + Xml::openElement( 'tr' ) . |
| 2137 | + '<td>' . |
| 2138 | + Xml::radio( 'wpFlaggedRevsSUI', 1, $form->mFlaggedRevsSUI==1, array('id' => 'simpleUI') ) . |
| 2139 | + '</td><td> ' . |
| 2140 | + Xml::label( wfMsgHtml('flaggedrevs-pref-UI-1'), 'simpleUI' ) . |
| 2141 | + '</td>' |
| 2142 | + ); |
| 2143 | + if( $wgUser->isAllowed( 'review' ) ) { |
| 2144 | + $out->addHTML( |
| 2145 | + Xml::closeElement( 'tr' ) . |
| 2146 | + Xml::openElement( 'tr' ) . '<td><br/></td>' . Xml::closeElement( 'tr' ) . |
| 2147 | + Xml::openElement( 'tr' ) . |
| 2148 | + '<td>' . wfCheck( 'wpFlaggedRevsWatch', $form->mFlaggedRevsWatch, array('id' => 'wpFlaggedRevsWatch') ) . |
| 2149 | + '</td><td> ' . wfLabel( wfMsg( 'flaggedrevs-prefs-watch' ), 'wpFlaggedRevsWatch' ) . '</td>' |
| 2150 | + ); |
| 2151 | + } |
| 2152 | + $out->addHTML( |
| 2153 | + Xml::closeElement( 'tr' ) . |
| 2154 | + Xml::closeElement( 'table' ) . |
| 2155 | + Xml::closeElement( 'fieldset' ) |
| 2156 | + ); |
| 2157 | + |
2151 | 2158 | return true; |
2152 | 2159 | } |
2153 | 2160 | |
— | — | @@ -2206,21 +2213,4 @@ |
2207 | 2214 | } |
2208 | 2215 | } |
2209 | 2216 | |
2210 | | -function efFlaggedRevsSchemaUpdates() { |
2211 | | - global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables; |
2212 | 2217 | |
2213 | | - $base = dirname(__FILE__); |
2214 | | - if( $wgDBtype == 'mysql' ) { |
2215 | | - $wgExtNewFields[] = array( 'flaggedpage_config', 'fpc_expiry', "$base/archives/patch-fpc_expiry.sql" ); |
2216 | | - $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/archives/patch-expiry-index.sql" ); |
2217 | | - $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/archives/patch-flaggedrevs_promote.sql" ); |
2218 | | - $wgExtNewTables[] = array( 'flaggedpages', "$base/archives/patch-flaggedpages.sql" ); |
2219 | | - } else if( $wgDBtype == 'postgres' ) { |
2220 | | - $wgExtPGNewFields[] = array('flaggedpage_config', 'fpc_expiry', "TIMESTAMPTZ NULL" ); |
2221 | | - $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/postgres/patch-expiry-index.sql" ); |
2222 | | - $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/postgres/patch-flaggedrevs_promote.sql" ); |
2223 | | - $wgExtNewTables[] = array( 'flaggedpages', "$base/postgres/patch-flaggedpages.sql" ); |
2224 | | - } |
2225 | | - |
2226 | | - return true; |
2227 | | -} |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsXML.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | |
30 | 30 | $name = $index !== 0 ? $name : wfMsg('blanknamespace'); |
31 | 31 | |
32 | | - if( $index === $selected ) { |
| 32 | + if($index === $selected) { |
33 | 33 | $s .= "\t" . Xml::element("option", array("value" => $index, "selected" => "selected"), $name) . "\n"; |
34 | 34 | } else { |
35 | 35 | $s .= "\t" . Xml::element("option", array("value" => $index), $name) . "\n"; |
— | — | @@ -117,12 +117,8 @@ |
118 | 118 | $msg = $quality ? 'revreview-quality-old' : 'revreview-basic-old'; |
119 | 119 | $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time ); |
120 | 120 | } else { |
121 | | - if( $stable ) { |
122 | | - $msg = $quality ? 'revreview-quality' : 'revreview-basic'; |
123 | | - $msg .= ($revs_since == 0) ? '-i' : ''; |
124 | | - } else { |
125 | | - $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic'; |
126 | | - } |
| 121 | + $msg = $stable ? 'revreview-' : 'revreview-newest-'; |
| 122 | + $msg .= $quality ? 'quality' : 'basic'; |
127 | 123 | $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time, $revs_since ); |
128 | 124 | } |
129 | 125 | # Make fancy box... |
— | — | @@ -141,45 +137,4 @@ |
142 | 138 | |
143 | 139 | return $box; |
144 | 140 | } |
145 | | - |
146 | | - /** |
147 | | - * Add user preference to form HTML |
148 | | - */ |
149 | | - public static function stabilityPreferences( $form ) { |
150 | | - global $wgUser; |
151 | | - |
152 | | - $html = Xml::openElement( 'fieldset' ) . |
153 | | - Xml::element( 'legend', null, wfMsgHtml('flaggedrevs-prefs') ) . |
154 | | - Xml::openElement( 'table' ) . |
155 | | - Xml::openElement( 'tr' ) . |
156 | | - '<td>' . wfCheck( 'wpFlaggedRevsStable', $form->mFlaggedRevsStable, |
157 | | - array('id' => 'wpFlaggedRevsStable') ) . '</td><td> ' . |
158 | | - wfLabel( wfMsg( 'flaggedrevs-prefs-stable' ), 'wpFlaggedRevsStable' ) . '</td>' . |
159 | | - Xml::closeElement( 'tr' ) . |
160 | | - Xml::openElement( 'tr' ) . |
161 | | - '<td>' . |
162 | | - Xml::radio( 'wpFlaggedRevsSUI', 0, $form->mFlaggedRevsSUI==0, array('id' => 'standardUI') ) . |
163 | | - '</td><td> ' . |
164 | | - Xml::label( wfMsgHtml('flaggedrevs-pref-UI-0'), 'standardUI' ) . |
165 | | - '</td>' . |
166 | | - Xml::closeElement( 'tr' ) . |
167 | | - Xml::openElement( 'tr' ) . |
168 | | - '<td>' . |
169 | | - Xml::radio( 'wpFlaggedRevsSUI', 1, $form->mFlaggedRevsSUI==1, array('id' => 'simpleUI') ) . |
170 | | - '</td><td> ' . |
171 | | - Xml::label( wfMsgHtml('flaggedrevs-pref-UI-1'), 'simpleUI' ) . |
172 | | - '</td>'; |
173 | | - if( $wgUser->isAllowed( 'review' ) ) { |
174 | | - $html .= Xml::closeElement( 'tr' ) . |
175 | | - Xml::openElement( 'tr' ) . '<td><br/></td>' . Xml::closeElement( 'tr' ) . |
176 | | - Xml::openElement( 'tr' ) . |
177 | | - '<td>' . wfCheck( 'wpFlaggedRevsWatch', $form->mFlaggedRevsWatch, array('id' => 'wpFlaggedRevsWatch') ) . |
178 | | - '</td><td> ' . wfLabel( wfMsg( 'flaggedrevs-prefs-watch' ), 'wpFlaggedRevsWatch' ) . '</td>'; |
179 | | - } |
180 | | - $html .= Xml::closeElement( 'tr' ) . |
181 | | - Xml::closeElement( 'table' ) . |
182 | | - Xml::closeElement( 'fieldset' ); |
183 | | - |
184 | | - return $html; |
185 | | - } |
186 | 141 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -1,8 +1,9 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class FlaggedArticle extends Article { |
| 4 | +class FlaggedArticle { |
5 | 5 | public $isDiffFromStable = false; |
6 | 6 | public $skipReviewDiff = false; |
| 7 | + public $skipAutoReview = false; |
7 | 8 | public $stableRev = null; |
8 | 9 | public $pageconfig = null; |
9 | 10 | public $flags = null; |
— | — | @@ -74,7 +75,9 @@ |
75 | 76 | * Is this article reviewable? |
76 | 77 | */ |
77 | 78 | public function isReviewable() { |
78 | | - return FlaggedRevs::isPageReviewable( $this->getTitle() ); |
| 79 | + global $wgTitle; |
| 80 | + |
| 81 | + return FlaggedRevs::isPageReviewable( $wgTitle ); |
79 | 82 | } |
80 | 83 | |
81 | 84 | /** |
— | — | @@ -82,7 +85,12 @@ |
83 | 86 | */ |
84 | 87 | private function displayTag() { |
85 | 88 | global $wgOut; |
| 89 | + |
| 90 | + if( !$this->reviewNotice ) { |
| 91 | + return false; |
| 92 | + } |
86 | 93 | $wgOut->appendSubtitle( $this->reviewNotice ); |
| 94 | + |
87 | 95 | return true; |
88 | 96 | } |
89 | 97 | |
— | — | @@ -168,7 +176,13 @@ |
169 | 177 | // behavior below, since it is the same as ("&stable=1"). |
170 | 178 | if( $old ) { |
171 | 179 | $revs_since = FlaggedRevs::getRevCountSince( $article, $frev->getRevId() ); |
172 | | - $text = $frev->getTextForParse(); |
| 180 | + global $wgUseStableTemplates; |
| 181 | + if( $wgUseStableTemplates ) { |
| 182 | + $rev = Revision::newFromId( $frev->getRevId() ); |
| 183 | + $text = $rev->getText(); |
| 184 | + } else { |
| 185 | + $text = $frev->getExpandedText(); |
| 186 | + } |
173 | 187 | $parserOut = FlaggedRevs::parseStableText( $article, $text, $frev->getRevId() ); |
174 | 188 | # Construct some tagging for non-printable outputs. Note that the pending |
175 | 189 | # notice has all this info already, so don't do this if we added that already. |
— | — | @@ -272,7 +286,13 @@ |
273 | 287 | # Get parsed stable version |
274 | 288 | $parserOut = FlaggedRevs::getPageCache( $article ); |
275 | 289 | if( $parserOut==false ) { |
276 | | - $text = $frev->getTextForParse(); |
| 290 | + global $wgUseStableTemplates; |
| 291 | + if( $wgUseStableTemplates ) { |
| 292 | + $rev = Revision::newFromId( $frev->getRevId() ); |
| 293 | + $text = $rev->getText(); |
| 294 | + } else { |
| 295 | + $text = $frev->getExpandedText(); |
| 296 | + } |
277 | 297 | $parserOut = FlaggedRevs::parseStableText( $article, $text, $frev->getRevId() ); |
278 | 298 | # Update the stable version cache |
279 | 299 | FlaggedRevs::updatePageCache( $article, $parserOut ); |
— | — | @@ -294,7 +314,6 @@ |
295 | 315 | // Standard UI |
296 | 316 | } else { |
297 | 317 | $msg = $quality ? 'revreview-quality' : 'revreview-basic'; |
298 | | - $msg .= ($revs_since == 0) ? '-i' : ''; |
299 | 318 | $msg = $synced ? "{$msg}-same" : $msg; |
300 | 319 | |
301 | 320 | $tag = "<span class='{$css} plainlinks' title=\"{$tooltip}\"></span>" . |
— | — | @@ -386,7 +405,7 @@ |
387 | 406 | * Adds latest stable version tag to page when editing |
388 | 407 | */ |
389 | 408 | public function addToEditView( $editform ) { |
390 | | - global $wgRequest, $wgOut; |
| 409 | + global $wgRequest, $wgTitle, $wgOut; |
391 | 410 | # Talk pages cannot be validated |
392 | 411 | if( !$editform->mArticle || !$this->isReviewable() ) |
393 | 412 | return false; |
— | — | @@ -403,7 +422,7 @@ |
404 | 423 | $tag = $warning = ''; |
405 | 424 | # Check the newest stable version |
406 | 425 | $frev = $this->getStableRev(); |
407 | | - if( !is_null($frev) ) { |
| 426 | + if( !is_null($frev) && $frev->getRevId() != $revid ) { |
408 | 427 | global $wgLang, $wgUser, $wgFlaggedRevsAutoReview; |
409 | 428 | |
410 | 429 | $time = $wgLang->date( $frev->getTimestamp(), true ); |
— | — | @@ -422,28 +441,26 @@ |
423 | 442 | wfMsgExt($msg,array('parseinline')) . "</div>"; |
424 | 443 | } |
425 | 444 | } |
426 | | - if( $frev->getRevId() != $revid ) { |
427 | | - # Streamlined UI |
428 | | - if( FlaggedRevs::useSimpleUI() ) { |
429 | | - $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic'; |
430 | | - $tag = "<span class='fr-checkbox'></span>" . |
431 | | - wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revs_since ); |
432 | | - $tag = "<div id='mw-revisiontag-edit' class='flaggedrevs_editnotice plainlinks'>$tag</div>"; |
433 | | - # Standard UI |
434 | | - } else { |
435 | | - $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic'; |
436 | | - $tag = "<span class='fr-checkbox'></span>" . |
437 | | - wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revs_since ); |
438 | | - # Hide clutter |
439 | | - if( !empty($flags) ) { |
440 | | - $tag .= " <span id='mw-revisiontoggle' class='flaggedrevs_toggle' style='display:none;'" . |
441 | | - " onclick='toggleRevRatings()' title='" . wfMsgHtml('revreview-toggle-title') . "' >" . |
442 | | - wfMsg( 'revreview-toggle' ) . "</span>"; |
443 | | - $tag .= '<span id="mw-revisionratings" style="display:block;">' . |
444 | | - wfMsg('revreview-oldrating') . FlaggedRevsXML::addTagRatings( $flags ) . '</span>'; |
445 | | - } |
446 | | - $tag = "<div id='mw-revisiontag-edit' class='flaggedrevs_editnotice plainlinks'>$tag</div>"; |
| 445 | + # Streamlined UI |
| 446 | + if( FlaggedRevs::useSimpleUI() ) { |
| 447 | + $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic'; |
| 448 | + $tag = "<span class='fr-checkbox'></span>" . |
| 449 | + wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revs_since ); |
| 450 | + $tag = "<div id='mw-revisiontag-edit' class='flaggedrevs_editnotice plainlinks'>$tag</div>"; |
| 451 | + # Standard UI |
| 452 | + } else { |
| 453 | + $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic'; |
| 454 | + $tag = "<span class='fr-checkbox'></span>" . |
| 455 | + wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revs_since ); |
| 456 | + # Hide clutter |
| 457 | + if( !empty($flags) ) { |
| 458 | + $tag .= " <span id='mw-revisiontoggle' class='flaggedrevs_toggle' style='display:none;'" . |
| 459 | + " onclick='toggleRevRatings()' title='" . wfMsgHtml('revreview-toggle-title') . "' >" . |
| 460 | + wfMsg( 'revreview-toggle' ) . "</span>"; |
| 461 | + $tag .= '<span id="mw-revisionratings" style="display:block;">' . |
| 462 | + wfMsg('revreview-oldrating') . FlaggedRevsXML::addTagRatings( $flags ) . '</span>'; |
447 | 463 | } |
| 464 | + $tag = "<div id='mw-revisiontag-edit' class='flaggedrevs_editnotice plainlinks'>$tag</div>"; |
448 | 465 | } |
449 | 466 | $wgOut->addHTML( $tag . $warning ); |
450 | 467 | # Show diff to stable, to make things less confusing |
— | — | @@ -519,7 +536,7 @@ |
520 | 537 | * Add link to stable version setting to protection form |
521 | 538 | */ |
522 | 539 | public function addVisibilityLink( $out ) { |
523 | | - global $wgUser, $wgRequest; |
| 540 | + global $wgUser, $wgRequest, $wgTitle; |
524 | 541 | |
525 | 542 | if( !$this->isReviewable() ) |
526 | 543 | return true; |
— | — | @@ -889,6 +906,108 @@ |
890 | 907 | |
891 | 908 | return true; |
892 | 909 | } |
| 910 | + |
| 911 | + /** |
| 912 | + * When a new page is made by a reviwer, try to automatically review it. |
| 913 | + */ |
| 914 | + public function maybeMakeNewPageReviewed( $article, $user, $text, $c, $flags, $a, $b, $flags, $rev ) { |
| 915 | + global $wgFlaggedRevsAutoReviewNew; |
| 916 | + |
| 917 | + if( $this->skipAutoReview || !$wgFlaggedRevsAutoReviewNew || !$user->isAllowed('autoreview') ) |
| 918 | + return true; |
| 919 | + # Must be in reviewable namespace |
| 920 | + if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) |
| 921 | + return true; |
| 922 | + # Revision will be null for null edits |
| 923 | + if( !$rev ) { |
| 924 | + $this->skipReviewDiff = true; // Don't jump to diff... |
| 925 | + return true; |
| 926 | + } |
| 927 | + # Assume basic flagging level |
| 928 | + $flags = array(); |
| 929 | + foreach( FlaggedRevs::$dimensions as $tag => $minQL ) { |
| 930 | + $flags[$tag] = 1; |
| 931 | + } |
| 932 | + FlaggedRevs::autoReviewEdit( $article, $user, $text, $rev, $flags ); |
| 933 | + |
| 934 | + $this->skipReviewDiff = true; // Don't jump to diff... |
| 935 | + $this->skipAutoReview = true; // Be sure not to do stuff twice |
| 936 | + |
| 937 | + return true; |
| 938 | + } |
| 939 | + |
| 940 | + /** |
| 941 | + * When an edit is made by a reviewer, if the current revision is the stable |
| 942 | + * version, try to automatically review it. |
| 943 | + */ |
| 944 | + public function maybeMakeEditReviewed( $article, $user, $text, $c, $m, $a, $b, $flags, $rev ) { |
| 945 | + global $wgFlaggedRevsAutoReview, $wgRequest; |
| 946 | + |
| 947 | + if( $this->skipAutoReview || !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) |
| 948 | + return true; |
| 949 | + # Must be in reviewable namespace |
| 950 | + if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) |
| 951 | + return true; |
| 952 | + # Revision will be null for null edits |
| 953 | + if( !$rev ) { |
| 954 | + $this->skipReviewDiff = true; // Don't jump to diff... |
| 955 | + return true; |
| 956 | + } |
| 957 | + # Get the revision the incoming one was based off |
| 958 | + $baseRevID = $wgRequest->getVal('baseRevId'); |
| 959 | + $frev = FlaggedRevs::getFlaggedRev( $article->getTitle(), $baseRevID ); |
| 960 | + # Is this an edit directly to the stable version? |
| 961 | + if( is_null($frev) ) |
| 962 | + return true; |
| 963 | + # Assume basic flagging level |
| 964 | + $flags = array(); |
| 965 | + foreach( FlaggedRevs::$dimensions as $tag => $minQL ) { |
| 966 | + $flags[$tag] = 1; |
| 967 | + } |
| 968 | + FlaggedRevs::autoReviewEdit( $article, $user, $text, $rev, $flags ); |
| 969 | + |
| 970 | + $this->skipReviewDiff = true; // Don't jump to diff... |
| 971 | + $this->skipAutoReview = true; // Be sure not to do stuff twice |
| 972 | + |
| 973 | + return true; |
| 974 | + } |
| 975 | + |
| 976 | + /** |
| 977 | + * When a rollback is made by a reviwer, try to automatically review it. |
| 978 | + */ |
| 979 | + public function maybeMakeRollbackReviewed( $article, $user, $rev ) { |
| 980 | + global $wgFlaggedRevsAutoReview; |
| 981 | + |
| 982 | + if( $this->skipAutoReview || !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) |
| 983 | + return true; |
| 984 | + # Must be in reviewable namespace |
| 985 | + if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) |
| 986 | + return true; |
| 987 | + # Was this revision flagged? |
| 988 | + $frev = FlaggedRevs::getFlaggedRev( $article->getTitle(), $rev->getId() ); |
| 989 | + if( is_null($frev) ) |
| 990 | + return true; |
| 991 | + # Grab the flags for this revision |
| 992 | + $flags = FlaggedRevs::getRevisionTags( $article->getTitle(), $rev->getID() ); |
| 993 | + # Check if user is allowed to renew the stable version. |
| 994 | + if( !RevisionReview::userCanSetFlags( $flags ) ) { |
| 995 | + # Assume basic flagging level |
| 996 | + $flags = array(); |
| 997 | + foreach( FlaggedRevs::$dimensions as $tag => $minQL ) { |
| 998 | + $flags[$tag] = 1; |
| 999 | + } |
| 1000 | + } |
| 1001 | + # Select the version that is now current. Create a new article object |
| 1002 | + # to avoid using one with outdated field data. |
| 1003 | + $article = new Article( $article->getTitle() ); |
| 1004 | + $newRev = Revision::newFromId( $article->getLatest() ); |
| 1005 | + FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $newRev, $flags ); |
| 1006 | + |
| 1007 | + $this->skipReviewDiff = true; // Don't jump to diff... |
| 1008 | + $this->skipAutoReview = true; // Be sure not to do stuff twice |
| 1009 | + |
| 1010 | + return true; |
| 1011 | + } |
893 | 1012 | |
894 | 1013 | /** |
895 | 1014 | * Add a hidden revision ID field to edit form. |
— | — | @@ -928,7 +1047,8 @@ |
929 | 1048 | return $this->stableRev; |
930 | 1049 | } |
931 | 1050 | # Get the content page, skip talk |
932 | | - $title = $this->getTitle()->getSubjectPage(); |
| 1051 | + global $wgTitle; |
| 1052 | + $title = $wgTitle->getSubjectPage(); |
933 | 1053 | # Do we have one? |
934 | 1054 | $srev = FlaggedRevs::getStablePageRev( $title, $getText, $forUpdate ); |
935 | 1055 | if( $srev ) { |
— | — | @@ -946,12 +1066,13 @@ |
947 | 1067 | * @returns Array (select,override) |
948 | 1068 | */ |
949 | 1069 | public function getVisibilitySettings( $forUpdate=false ) { |
| 1070 | + global $wgTitle; |
950 | 1071 | # Cached results available? |
951 | 1072 | if( !is_null($this->pageconfig) ) { |
952 | 1073 | return $this->pageconfig; |
953 | 1074 | } |
954 | 1075 | # Get the content page, skip talk |
955 | | - $title = $this->getTitle()->getSubjectPage(); |
| 1076 | + $title = $wgTitle->getSubjectPage(); |
956 | 1077 | |
957 | 1078 | $config = FlaggedRevs::getPageVisibilitySettings( $title, $forUpdate ); |
958 | 1079 | $this->pageconfig = $config; |
— | — | @@ -964,12 +1085,12 @@ |
965 | 1086 | * @eturns Array, output of the flags for a given revision |
966 | 1087 | */ |
967 | 1088 | public function getFlagsForRevision( $rev_id ) { |
968 | | - global $wgFlaggedRevTags; |
| 1089 | + global $wgFlaggedRevTags, $wgTitle; |
969 | 1090 | # Cached results? |
970 | 1091 | if( isset($this->flags[$rev_id]) && $this->flags[$rev_id] ) |
971 | 1092 | return $this->flags[$rev_id]; |
972 | 1093 | # Get the flags |
973 | | - $flags = FlaggedRevs::getRevisionTags( $this->getTitle(), $rev_id ); |
| 1094 | + $flags = FlaggedRevs::getRevisionTags( $wgTitle, $rev_id ); |
974 | 1095 | # Try to cache results |
975 | 1096 | $this->flags[$rev_id] = $flags; |
976 | 1097 | |
— | — | @@ -983,7 +1104,7 @@ |
984 | 1105 | * @param bool $top, should this form always go on top? |
985 | 1106 | */ |
986 | 1107 | public function addQuickReview( $out, $top = false ) { |
987 | | - global $wgOut, $wgUser, $wgRequest, $wgFlaggedRevComments, $wgFlaggedRevsOverride; |
| 1108 | + global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgFlaggedRevComments, $wgFlaggedRevsOverride; |
988 | 1109 | # User must have review rights |
989 | 1110 | if( !$wgUser->isAllowed( 'review' ) ) { |
990 | 1111 | return; |
— | — | @@ -1112,16 +1233,16 @@ |
1113 | 1234 | } |
1114 | 1235 | } |
1115 | 1236 | # For image pages, note the current image version |
1116 | | - if( $this->getTitle()->getNamespace() == NS_IMAGE ) { |
1117 | | - $file = wfFindFile( $this->getTitle() ); |
| 1237 | + if( $wgTitle->getNamespace() == NS_IMAGE ) { |
| 1238 | + $file = wfFindFile( $wgTitle ); |
1118 | 1239 | if( $file ) { |
1119 | | - $imageParams .= $this->getTitle()->getDBkey() . "|" . $file->getTimestamp() . "|" . $file->getSha1() . "#"; |
| 1240 | + $imageParams .= $wgTitle->getDBkey() . "|" . $file->getTimestamp() . "|" . $file->getSha1() . "#"; |
1120 | 1241 | } |
1121 | 1242 | } |
1122 | 1243 | |
1123 | 1244 | # Hidden params |
1124 | 1245 | $form .= Xml::hidden( 'title', $reviewtitle->getPrefixedText() ) . "\n"; |
1125 | | - $form .= Xml::hidden( 'target', $this->getTitle()->getPrefixedText() ) . "\n"; |
| 1246 | + $form .= Xml::hidden( 'target', $wgTitle->getPrefixedText() ) . "\n"; |
1126 | 1247 | $form .= Xml::hidden( 'oldid', $id ) . "\n"; |
1127 | 1248 | $form .= Xml::hidden( 'action', 'submit') . "\n"; |
1128 | 1249 | $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n"; |
— | — | @@ -1189,18 +1310,11 @@ |
1190 | 1311 | * If viewing a stable version, adjust the last modified header |
1191 | 1312 | */ |
1192 | 1313 | public function setLastModified( $sktmp, &$tpl ) { |
1193 | | - global $wgArticle, $wgLang, $wgRequest; |
| 1314 | + global $wgArticle, $wgLang; |
1194 | 1315 | # Non-content pages cannot be validated |
1195 | | - if( !$this->isReviewable() ) |
| 1316 | + if( !$this->pageOverride() ) |
1196 | 1317 | return true; |
1197 | | - # Old stable versions |
1198 | | - if( $wgRequest->getIntOrNull('stableid') ) { |
1199 | | - $tpl->set('lastmod', false); |
1200 | | - return true; |
1201 | | - } |
1202 | 1318 | # Check for an overridabe revision |
1203 | | - if( !$this->pageOverride() ) |
1204 | | - return true; |
1205 | 1319 | $frev = $this->getStableRev( true ); |
1206 | 1320 | if( !$frev || $frev->getRevId() == $wgArticle->getLatest() ) |
1207 | 1321 | return true; |
— | — | @@ -1245,3 +1359,5 @@ |
1246 | 1360 | return true; |
1247 | 1361 | } |
1248 | 1362 | } |
| 1363 | + |
| 1364 | + |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | 'tooltip-ca-default' => 'Quality assurance settings', |
43 | 43 | |
44 | 44 | 'revreview-edited' => "'''Edits will be incorporated into the [[{{MediaWiki:Validationpage}}|stable version]] once an established user reviews them. |
45 | | -The ''draft'' is shown below.''' [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} $2 {{plural:$2|change awaits|changes await}}] review.", |
| 45 | +The ''draft'' is shown below.''' [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} $2 {{plural:$2|change|changes}}] await review.", |
46 | 46 | |
47 | 47 | 'validationpage' => '{{ns:help}}:Article validation', |
48 | 48 | |
— | — | @@ -66,10 +66,6 @@ |
67 | 67 | The [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} draft] has [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} $3 {{plural:$3|change|changes}}] awaiting review.', |
68 | 68 | 'revreview-quality' => 'This is the latest [[{{MediaWiki:Validationpage}}|quality]] revision, [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved] on <i>$2</i>. |
69 | 69 | The [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} draft] has [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} $3 {{plural:$3|change|changes}}] awaiting review.', |
70 | | - 'revreview-basic-i' => 'This is the latest [[{{MediaWiki:Validationpage}}|sighted]] revision, [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved] on <i>$2</i>. |
71 | | -The [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} draft] has [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} template/image changes] awaiting review.', |
72 | | - 'revreview-quality-i' => 'This is the latest [[{{MediaWiki:Validationpage}}|quality]] revision, [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved] on <i>$2</i>. |
73 | | -The [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} draft] has [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} template/image changes] awaiting review.', |
74 | 70 | 'revreview-basic-same' => 'This is the latest [[{{MediaWiki:Validationpage}}|sighted]] revision ([{{fullurl:Special:Stableversions|page={{FULLPAGENAMEE}}}} list all]), [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved] on <i>$2</i>.', |
75 | 71 | 'revreview-quality-same' => 'This is the latest [[{{MediaWiki:Validationpage}}|quality]] revision ([{{fullurl:Special:Stableversions|page={{FULLPAGENAMEE}}}} list all]), [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved] on <i>$2</i>.', |
76 | 72 | 'revreview-basic-old' => 'This is a [[{{MediaWiki:Validationpage}}|sighted]] revision ([{{fullurl:Special:Stableversions|page={{FULLPAGENAMEE}}}} list all]), [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved] on <i>$2</i>. |
Index: trunk/extensions/FlaggedRevs/README.txt |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * Download the extension from SVN |
7 | 7 | * (MySQL) Run the 'FlaggedRevs.sql' query, substituting in your wiki's table prefix. |
8 | 8 | * (PostgreSQL) Use 'FlaggedRevs.pg.sql' instead. |
9 | | -* Upgrade to MediaWiki 1.13+ |
| 9 | +* Upgrade to MediaWiki 1.12+ |
10 | 10 | * Run 'maintenance/update.php' |
11 | 11 | * Run 'maintenance/archives/populateSha1.php'. |
12 | 12 | * Add the following line to 'LocalSettings.php': |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php |
— | — | @@ -594,9 +594,7 @@ |
595 | 595 | $u = new LinksUpdate( $this->page, $poutput ); |
596 | 596 | $u->doUpdate(); // Will trigger our hook to add stable links too... |
597 | 597 | # Might as well save the cache, since it should be the same |
598 | | - global $wgEnableParserCache; |
599 | | - if( $wgEnableParserCache ) |
600 | | - $parserCache->save( $poutput, $article, $wgUser ); |
| 598 | + $parserCache->save( $poutput, $article, $wgUser ); |
601 | 599 | # Purge squid for this page only |
602 | 600 | $article->getTitle()->purgeSquid(); |
603 | 601 | |
— | — | @@ -648,9 +646,7 @@ |
649 | 647 | # Clear the cache... |
650 | 648 | $this->page->invalidateCache(); |
651 | 649 | # Might as well save the cache |
652 | | - global $wgEnableParserCache; |
653 | | - if( $wgEnableParserCache ) |
654 | | - $parserCache->save( $poutput, $article, $wgUser ); |
| 650 | + $parserCache->save( $poutput, $article, $wgUser ); |
655 | 651 | # Purge squid for this page only |
656 | 652 | $this->page->purgeSquid(); |
657 | 653 | |
— | — | @@ -901,17 +897,15 @@ |
902 | 898 | ' ' . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" . |
903 | 899 | "</fieldset></form>" |
904 | 900 | ); |
905 | | - # This will start to get slower... |
906 | | - if( $category || self::generalQueryOK() ) { |
907 | | - $pager = new UnreviewedPagesPager( $this, $namespace, $category ); |
908 | | - if( $pager->getNumRows() ) { |
909 | | - $wgOut->addHTML( wfMsgExt('unreviewed-list', array('parse') ) ); |
910 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
911 | | - $wgOut->addHTML( "<ul>" . $pager->getBody() . "</ul>" ); |
912 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
913 | | - } else { |
914 | | - $wgOut->addHTML( wfMsgExt('unreviewed-none', array('parse') ) ); |
915 | | - } |
| 901 | + |
| 902 | + $pager = new UnreviewedPagesPager( $this, $namespace, $category ); |
| 903 | + if( $pager->getNumRows() ) { |
| 904 | + $wgOut->addHTML( wfMsgExt('unreviewed-list', array('parse') ) ); |
| 905 | + $wgOut->addHTML( $pager->getNavigationBar() ); |
| 906 | + $wgOut->addHTML( "<ul>" . $pager->getBody() . "</ul>" ); |
| 907 | + $wgOut->addHTML( $pager->getNavigationBar() ); |
| 908 | + } else { |
| 909 | + $wgOut->addHTML( wfMsgExt('unreviewed-none', array('parse') ) ); |
916 | 910 | } |
917 | 911 | } |
918 | 912 | |
— | — | @@ -951,22 +945,6 @@ |
952 | 946 | array( 'LIMIT' => 5 ) ); |
953 | 947 | return $res->numRows(); |
954 | 948 | } |
955 | | - |
956 | | - /** |
957 | | - * There may be many pages, most of which are reviewed |
958 | | - */ |
959 | | - public static function generalQueryOK() { |
960 | | - global $wgFlaggedRevsNamespaces; |
961 | | - if( !wfQueriesMustScale() ) |
962 | | - return true; |
963 | | - # Get est. of fraction of pages that are reviewed |
964 | | - $dbr = wfGetDB( DB_SLAVE ); |
965 | | - $reviewedpages = $dbr->estimateRowCount( 'flaggedpages', '*', array(), __METHOD__ ); |
966 | | - $pages = $dbr->estimateRowCount( 'page', '*', array('page_namespace' => $wgFlaggedRevsNamespaces), __METHOD__ ); |
967 | | - $ratio = $pages/($pages - $reviewedpages); |
968 | | - # If dist. is normalized, # of rows scanned = $ratio * LIMIT (or until list runs out) |
969 | | - return ($ratio <= 100); |
970 | | - } |
971 | 949 | } |
972 | 950 | |
973 | 951 | /** |
— | — | @@ -999,6 +977,7 @@ |
1000 | 978 | |
1001 | 979 | function getQueryInfo() { |
1002 | 980 | $conds = $this->mConds; |
| 981 | + $tables = array( 'page', 'flaggedpages' ); |
1003 | 982 | $fields = array('page_namespace','page_title','page_len','fp_stable'); |
1004 | 983 | $conds[] = 'fp_reviewed IS NULL'; |
1005 | 984 | # Reviewable pages only |
— | — | @@ -1007,26 +986,69 @@ |
1008 | 987 | $conds['page_is_redirect'] = 0; |
1009 | 988 | # Filter by category |
1010 | 989 | if( $this->category ) { |
1011 | | - $tables = array( 'categorylinks', 'page', 'flaggedpages' ); |
| 990 | + $tables[] = 'categorylinks'; |
1012 | 991 | $fields[] = 'cl_sortkey'; |
1013 | 992 | $conds['cl_to'] = $this->category; |
1014 | 993 | $conds[] = 'cl_from = page_id'; |
1015 | 994 | $this->mIndexField = 'cl_sortkey'; |
1016 | | - $useIndex = array( 'categorylinks' => 'cl_sortkey' ); |
1017 | 995 | } else { |
1018 | | - $tables = array( 'page', 'flaggedpages' ); |
1019 | 996 | $fields[] = 'page_id'; |
1020 | 997 | $this->mIndexField = 'page_title'; |
1021 | | - $useIndex = array( 'page' => 'name_title' ); |
1022 | 998 | } |
1023 | 999 | return array( |
1024 | 1000 | 'tables' => $tables, |
1025 | 1001 | 'fields' => $fields, |
1026 | 1002 | 'conds' => $conds, |
1027 | | - 'options' => array( 'USE INDEX' => $useIndex ), |
1028 | | - 'join_conds' => array( 'flaggedpages' => array('LEFT JOIN','fp_page_id=page_id') ) |
| 1003 | + 'options' => array() |
1029 | 1004 | ); |
1030 | 1005 | } |
| 1006 | + |
| 1007 | + /** |
| 1008 | + * Do a query with specified parameters, rather than using the object |
| 1009 | + * context |
| 1010 | + * |
| 1011 | + * @param string $offset Index offset, inclusive |
| 1012 | + * @param integer $limit Exact query limit |
| 1013 | + * @param boolean $descending Query direction, false for ascending, true for descending |
| 1014 | + * @return ResultWrapper |
| 1015 | + */ |
| 1016 | + function reallyDoQuery( $offset, $limit, $descending ) { |
| 1017 | + $fname = __METHOD__ . ' (' . get_class( $this ) . ')'; |
| 1018 | + $info = $this->getQueryInfo(); |
| 1019 | + $tables = $info['tables']; |
| 1020 | + $fields = $info['fields']; |
| 1021 | + $conds = isset( $info['conds'] ) ? $info['conds'] : array(); |
| 1022 | + $options = isset( $info['options'] ) ? $info['options'] : array(); |
| 1023 | + if ( $descending ) { |
| 1024 | + $options['ORDER BY'] = $this->mIndexField; |
| 1025 | + $operator = '>'; |
| 1026 | + } else { |
| 1027 | + $options['ORDER BY'] = $this->mIndexField . ' DESC'; |
| 1028 | + $operator = '<'; |
| 1029 | + } |
| 1030 | + if ( $offset != '' ) { |
| 1031 | + $conds[] = $this->mIndexField . $operator . $this->mDb->addQuotes( $offset ); |
| 1032 | + } |
| 1033 | + $options['LIMIT'] = intval( $limit ); |
| 1034 | + # Get table names |
| 1035 | + list($flaggedpages,$page,$categorylinks) = $this->mDb->tableNamesN('flaggedpages','page','categorylinks'); |
| 1036 | + # Are we filtering via category? |
| 1037 | + if( in_array('categorylinks',$tables) ) { |
| 1038 | + $index = $this->mDb->useIndexClause('cl_sortkey'); // *sigh*... |
| 1039 | + $fromClause = "$categorylinks $index, $page"; |
| 1040 | + } else { |
| 1041 | + $index = $this->mDb->useIndexClause('name_title'); // *sigh*... |
| 1042 | + $fromClause = "$page $index"; |
| 1043 | + } |
| 1044 | + $sql = "SELECT ".implode(',',$fields). |
| 1045 | + " FROM $fromClause". |
| 1046 | + " LEFT JOIN $flaggedpages ON (fp_page_id=page_id)". |
| 1047 | + " WHERE ".$this->mDb->makeList($conds,LIST_AND). |
| 1048 | + " ORDER BY ".$options['ORDER BY']." LIMIT ".$options['LIMIT']; |
| 1049 | + # Do query! |
| 1050 | + $res = $this->mDb->query( $sql ); |
| 1051 | + return new ResultWrapper( $this->mDb, $res ); |
| 1052 | + } |
1031 | 1053 | |
1032 | 1054 | function getIndexField() { |
1033 | 1055 | return $this->mIndexField; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -101,13 +101,6 @@ |
102 | 102 | public function getComment() { |
103 | 103 | return $this->mComment; |
104 | 104 | } |
105 | | - |
106 | | - /** |
107 | | - * @returns Integer the user ID of the reviewer |
108 | | - */ |
109 | | - public function getUser() { |
110 | | - return $this->mUser; |
111 | | - } |
112 | 105 | |
113 | 106 | /** |
114 | 107 | * @returns Integer revision timestamp in MW format |
— | — | @@ -130,20 +123,12 @@ |
131 | 124 | $this->loadText(); // load if not loaded |
132 | 125 | return $this->mText; |
133 | 126 | } |
134 | | - |
| 127 | + |
135 | 128 | /** |
136 | | - * @returns mixed (string/false) expanded text or revision text. |
137 | | - * Depends on whether $wgUseStableTemplates is on or not. |
| 129 | + * @returns Integer the user ID of the reviewer |
138 | 130 | */ |
139 | | - public function getTextForParse() { |
140 | | - global $wgUseStableTemplates; |
141 | | - if( $wgUseStableTemplates ) { |
142 | | - $rev = Revision::newFromId( $this->getRevId() ); |
143 | | - $text = $rev->getText(); |
144 | | - } else { |
145 | | - $text = $this->getExpandedText(); |
146 | | - } |
147 | | - return $text; |
| 131 | + public function getUser() { |
| 132 | + return $this->mUser; |
148 | 133 | } |
149 | 134 | |
150 | 135 | /** |