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.041', |
| 18 | + 'version' => '1.042', |
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 = new FlaggedArticle(); |
| 227 | + $wgFlaggedArticle = null; |
228 | 228 | |
229 | 229 | wfLoadExtensionMessages( 'FlaggedRevsPage' ); |
230 | 230 | |
— | — | @@ -238,28 +238,8 @@ |
239 | 239 | define( 'FLAGGED_JS', $wgScriptPath . '/extensions/FlaggedRevs/flaggedrevs.js?' . $wgFlaggedRevStyleVersion ); |
240 | 240 | |
241 | 241 | ######### Hook attachments ######### |
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' ); |
| 242 | + # Set $wgFlaggedArticle |
| 243 | + $wgHooks['ArticleFromTitle'][] = 'wfInitFlaggedArticle'; |
264 | 244 | # Autopromote Editors |
265 | 245 | $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevs::autoPromoteUser'; |
266 | 246 | # Adds table link references to include ones from the stable version |
— | — | @@ -281,17 +261,10 @@ |
282 | 262 | # Additional parser versioning |
283 | 263 | $wgHooks['ParserAfterTidy'][] = 'FlaggedRevs::parserInjectTimestamps'; |
284 | 264 | $wgHooks['OutputPageParserOutput'][] = 'FlaggedRevs::outputInjectTimestamps'; |
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' ); |
| 265 | + # Auto-reviewing |
294 | 266 | $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevs::autoMarkPatrolled'; |
295 | | - $wgHooks['RevisionInsertComplete'][] = 'FlaggedRevs::maybeMakeNullEditReviewed'; |
| 267 | + $wgHooks['RevisionInsertComplete'][] = 'FlaggedRevs::maybeMakeEditReviewed'; |
| 268 | + $wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevs::maybeMakeRollbackReviewed'; |
296 | 269 | # Disallow moves of stable pages |
297 | 270 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanMove'; |
298 | 271 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanView'; |
— | — | @@ -307,6 +280,44 @@ |
308 | 281 | ######### |
309 | 282 | } |
310 | 283 | |
| 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 | + |
311 | 322 | # Add review log and such |
312 | 323 | $wgLogTypes[] = 'review'; |
313 | 324 | $wgLogNames['review'] = 'review-logpage'; |
— | — | @@ -326,25 +337,6 @@ |
327 | 338 | |
328 | 339 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'efFlaggedRevsSchemaUpdates'; |
329 | 340 | |
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 | | - |
349 | 341 | class FlaggedRevs { |
350 | 342 | public static $dimensions = array(); |
351 | 343 | public static $styleLoaded = false; |
— | — | @@ -434,14 +426,14 @@ |
435 | 427 | */ |
436 | 428 | public static function parseStableText( $article, $text='', $id, $reparsed = true ) { |
437 | 429 | global $wgParser; |
| 430 | + $title = $article->getTitle(); // avoid pass-by-reference error |
438 | 431 | # Make our hooks to trigger |
439 | 432 | $wgParser->fr_isStable = true; |
440 | 433 | $wgParser->fr_includesMatched = true; |
441 | 434 | # Don't show section-edit links, they can be old and misleading |
442 | 435 | $options = self::makeParserOptions(); |
443 | | - $options->setEditSection( $id==$article->getLatest() ); |
| 436 | + $options->setEditSection( $id == $title->getLatestRevID(GAID_FOR_UPDATE) ); |
444 | 437 | # Parse the new body, wikitext -> html |
445 | | - $title = $article->getTitle(); // avoid pass-by-reference error |
446 | 438 | $parserOut = $wgParser->parse( $text, $title, $options, true, true, $id ); |
447 | 439 | $parserOut->fr_includesMatched = $wgParser->fr_includesMatched; |
448 | 440 | # Done with parser! |
— | — | @@ -490,14 +482,14 @@ |
491 | 483 | /** |
492 | 484 | * @param FlaggedRevision $frev |
493 | 485 | * @param Article $article |
494 | | - * @param ParserOutput $flaggedOutput, will fetch if not given |
| 486 | + * @param ParserOutput $stableOutput, will fetch if not given |
495 | 487 | * @param ParserOutput $currentOutput, will fetch if not given |
496 | 488 | * @return bool |
497 | 489 | * See if a flagged revision is synced with the current |
498 | 490 | */ |
499 | | - public static function flaggedRevIsSynced( $frev, $article, $flaggedOutput=null, $currentOutput=null ) { |
| 491 | + public static function flaggedRevIsSynced( $frev, $article, $stableOutput=null, $currentOutput=null ) { |
500 | 492 | # Must be the same revision |
501 | | - if( $frev->getRevId() != $article->getLatest() ) { |
| 493 | + if( $frev->getRevId() != $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) ) { |
502 | 494 | return false; |
503 | 495 | } |
504 | 496 | global $wgMemc; |
— | — | @@ -513,20 +505,14 @@ |
514 | 506 | } |
515 | 507 | } |
516 | 508 | # If parseroutputs not given, fetch them... |
517 | | - if( is_null($flaggedOutput) || !isset($flaggedOutput->fr_newestTemplateID) ) { |
| 509 | + if( is_null($stableOutput) || !isset($stableOutput->fr_newestTemplateID) ) { |
518 | 510 | # Get parsed stable version |
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() ); |
| 511 | + $stableOutput = self::getPageCache( $article ); |
| 512 | + if( $stableOutput==false ) { |
| 513 | + $text = $frev->getTextForParse(); |
| 514 | + $stableOutput = self::parseStableText( $article, $text, $frev->getRevId() ); |
529 | 515 | # Update the stable version cache |
530 | | - FlaggedRevs::updatePageCache( $article, $flaggedOutput ); |
| 516 | + self::updatePageCache( $article, $stableOutput ); |
531 | 517 | } |
532 | 518 | } |
533 | 519 | if( is_null($currentOutput) || !isset($currentOutput->fr_newestTemplateID) ) { |
— | — | @@ -540,15 +526,17 @@ |
541 | 527 | $options = self::makeParserOptions( $wgUser ); |
542 | 528 | $currentOutput = $wgParser->parse( $text, $title, $options ); |
543 | 529 | # Might as well save the cache while we're at it |
544 | | - $parserCache->save( $currentOutput, $article, $wgUser ); |
| 530 | + global $wgEnableParserCache; |
| 531 | + if( $wgEnableParserCache ) |
| 532 | + $parserCache->save( $currentOutput, $article, $wgUser ); |
545 | 533 | } |
546 | 534 | } |
547 | 535 | # Only current of revisions of inclusions can be reviewed. Since the stable and current revisions |
548 | 536 | # have the same text, the only thing that can make them different is updating a template or image. |
549 | 537 | # If this is the case, the current revision will have a newer template or image version used somewhere. |
550 | | - if( $currentOutput->fr_newestImageTime > $flaggedOutput->fr_newestImageTime ) { |
| 538 | + if( $currentOutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) { |
551 | 539 | $synced = false; |
552 | | - } else if( $currentOutput->fr_newestTemplateID > $flaggedOutput->fr_newestTemplateID ) { |
| 540 | + } else if( $currentOutput->fr_newestTemplateID > $stableOutput->fr_newestTemplateID ) { |
553 | 541 | $synced = false; |
554 | 542 | } else { |
555 | 543 | $synced = true; |
— | — | @@ -558,7 +546,7 @@ |
559 | 547 | global $wgParserCacheExpireTime; |
560 | 548 | $syncData = $synced ? "true" : "false"; |
561 | 549 | $wgMemc->set( $key, $syncData, $wgParserCacheExpireTime ); |
562 | | - |
| 550 | + |
563 | 551 | return $synced; |
564 | 552 | } |
565 | 553 | |
— | — | @@ -658,7 +646,6 @@ |
659 | 647 | if( $row ) { |
660 | 648 | return new FlaggedRevision( $title, $row ); |
661 | 649 | } |
662 | | - |
663 | 650 | return null; |
664 | 651 | } |
665 | 652 | |
— | — | @@ -670,11 +657,13 @@ |
671 | 658 | */ |
672 | 659 | public static function getRevQuality( $title, $rev_id, $db = NULL ) { |
673 | 660 | $db = $db ? $db : wfGetDB( DB_SLAVE ); |
674 | | - $quality = $db->selectField( 'flaggedrevs', 'fr_quality', |
| 661 | + $quality = $db->selectField( 'flaggedrevs', |
| 662 | + 'fr_quality', |
675 | 663 | array( 'fr_page_id' => $title->getArticleID(), |
676 | 664 | 'fr_rev_id' => $rev_id ), |
677 | 665 | __METHOD__, |
678 | | - array( 'FORCE INDEX' => 'PRIMARY' ) ); |
| 666 | + array( 'FORCE INDEX' => 'PRIMARY' ) |
| 667 | + ); |
679 | 668 | return $quality; |
680 | 669 | } |
681 | 670 | |
— | — | @@ -765,7 +754,7 @@ |
766 | 755 | # Check if the count is zero by using $article->getLatest(). |
767 | 756 | # I don't trust using memcache and PHP for values like '0' |
768 | 757 | # as it may confuse "expired" with "0". -aaron |
769 | | - if( $article->getLatest()==$from_rev ) { |
| 758 | + if( $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) == $from_rev ) { |
770 | 759 | return 0; |
771 | 760 | } |
772 | 761 | global $wgMemc; |
— | — | @@ -873,7 +862,7 @@ |
874 | 863 | public static function getRevisionTags( $title, $rev_id ) { |
875 | 864 | $dbr = wfGetDB( DB_SLAVE ); |
876 | 865 | $tags = $dbr->selectField( 'flaggedrevs', 'fr_tags', |
877 | | - array('fr_rev_id' => $rev_id, |
| 866 | + array( 'fr_rev_id' => $rev_id, |
878 | 867 | 'fr_page_id' => $title->getArticleId() ), |
879 | 868 | __METHOD__ ); |
880 | 869 | if( !$tags ) |
— | — | @@ -1045,10 +1034,10 @@ |
1046 | 1035 | /** |
1047 | 1036 | * Add FlaggedRevs css/js. Attached to two different hooks, neglect inputs. |
1048 | 1037 | */ |
1049 | | - public static function InjectStyleAndJS( $a=false, $b=false ) { |
| 1038 | + public static function InjectStyleAndJS() { |
1050 | 1039 | global $wgOut, $wgJsMimeType, $wgFlaggedArticle; |
1051 | 1040 | # Don't double-load |
1052 | | - if( self::$styleLoaded ) |
| 1041 | + if( self::$styleLoaded || !$wgFlaggedArticle ) |
1053 | 1042 | return true; |
1054 | 1043 | # UI CSS |
1055 | 1044 | $wgOut->addLink( array( |
— | — | @@ -1104,19 +1093,18 @@ |
1105 | 1094 | $quality = self::isPristine($flags) ? 2 : 1; |
1106 | 1095 | } |
1107 | 1096 | $tmpset = $imgset = array(); |
| 1097 | + $poutput = false; |
1108 | 1098 | # Try the parser cache, should be set on the edit before this is called. |
1109 | 1099 | # If not set or up to date, then parse it. Use master to avoid lag issues. |
1110 | | - $poutput = false; |
1111 | 1100 | $latestID = $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE); |
1112 | | - if( $latestID == $rev->getId() ) { |
1113 | | - $parserCache = ParserCache::singleton(); |
1114 | | - $poutput = $parserCache->get( $article, $user ); |
1115 | | - } |
1116 | | - if( $poutput==false ) { |
| 1101 | + if( $poutput == false ) { |
1117 | 1102 | $options = self::makeParserOptions( $user ); |
1118 | | - $poutput = $wgParser->parse( $text, $article->getTitle(), $options, true, true, $rev->getId() ); |
| 1103 | + $title = $article->getTitle(); // avoid pass-by-ref error |
| 1104 | + $poutput = $wgParser->parse( $text, $title, $options, true, true, $latestID ); |
1119 | 1105 | # Might as well save the cache while we're at it |
1120 | | - if( $latestID == $rev->getId() ) { |
| 1106 | + global $wgEnableParserCache; |
| 1107 | + if( $wgEnableParserCache && $latestID == $rev->getId() ) { |
| 1108 | + $parserCache = ParserCache::singleton(); |
1121 | 1109 | $parserCache->save( $poutput, $article, $user ); |
1122 | 1110 | } |
1123 | 1111 | } |
— | — | @@ -1163,7 +1151,7 @@ |
1164 | 1152 | $textFlags = self::compressText( $fulltext ); |
1165 | 1153 | |
1166 | 1154 | # Write to external storage if required |
1167 | | - $storage = FlaggedRevs::getExternalStorage(); |
| 1155 | + $storage = self::getExternalStorage(); |
1168 | 1156 | if( $storage ) { |
1169 | 1157 | if( is_array($storage) ) { |
1170 | 1158 | # Distribute storage across multiple clusters |
— | — | @@ -1219,7 +1207,7 @@ |
1220 | 1208 | $sv = self::getStablePageRev( $article->getTitle(), false, true ); |
1221 | 1209 | if( $sv && $sv->getRevId() == $rev->getId() ) { |
1222 | 1210 | # Update stable cache |
1223 | | - FlaggedRevs::updatePageCache( $article, $poutput ); |
| 1211 | + self::updatePageCache( $article, $poutput ); |
1224 | 1212 | # Update page fields |
1225 | 1213 | self::updateArticleOn( $article, $rev->getId(), $rev->getId() ); |
1226 | 1214 | # Purge squid for this page only |
— | — | @@ -1353,7 +1341,9 @@ |
1354 | 1342 | $options = self::makeParserOptions( $wgUser ); |
1355 | 1343 | $poutput = $wgParser->parse($text, $article->getTitle(), $options); |
1356 | 1344 | # Might as well save the cache while we're at it |
1357 | | - $parserCache->save( $poutput, $article, $wgUser ); |
| 1345 | + global $wgEnableParserCache; |
| 1346 | + if( $wgEnableParserCache ) |
| 1347 | + $parserCache->save( $poutput, $article, $wgUser ); |
1358 | 1348 | } |
1359 | 1349 | $u = new LinksUpdate( $article->getTitle(), $poutput ); |
1360 | 1350 | $u->doUpdate(); // this will trigger our hook to add stable links too... |
— | — | @@ -1390,12 +1380,7 @@ |
1391 | 1381 | # Try stable version cache. This should be updated before this is called. |
1392 | 1382 | $parserOut = self::getPageCache( $article ); |
1393 | 1383 | if( $parserOut==false ) { |
1394 | | - if( $wgUseStableTemplates ) { |
1395 | | - $rev = Revision::newFromId( $sv->getRevId() ); |
1396 | | - $text = $rev->getText(); |
1397 | | - } else { |
1398 | | - $text = $sv->getExpandedText(); |
1399 | | - } |
| 1384 | + $text = $sv->getTextForParse(); |
1400 | 1385 | # Parse the text |
1401 | 1386 | $parserOut = self::parseStableText( $article, $text, $sv->getRevId() ); |
1402 | 1387 | } |
— | — | @@ -1714,13 +1699,12 @@ |
1715 | 1700 | * Don't let users vandalize pages by moving them. |
1716 | 1701 | */ |
1717 | 1702 | public static function userCanMove( $title, $user, $action, $result ) { |
1718 | | - global $wgTitle; |
| 1703 | + global $wgTitle, $wgFlaggedArticle; |
1719 | 1704 | |
1720 | 1705 | if( $action != 'move' || !self::isPageReviewable( $title ) ) |
1721 | 1706 | return true; |
1722 | 1707 | # See if there is a stable version |
1723 | | - if( $wgTitle && $wgTitle->equals( $title ) ) { |
1724 | | - global $wgFlaggedArticle; |
| 1708 | + if( $wgFlaggedArticle && $wgTitle && $wgTitle->equals( $title ) ) { |
1725 | 1709 | // Cache stable version while we are at it. |
1726 | 1710 | $frev = $wgFlaggedArticle->getStableRev( true ); |
1727 | 1711 | } else { |
— | — | @@ -1741,7 +1725,7 @@ |
1742 | 1726 | * Allow users to view reviewed pages. |
1743 | 1727 | */ |
1744 | 1728 | public static function userCanView( $title, $user, $action, $result ) { |
1745 | | - global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle; |
| 1729 | + global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle, $wgFlaggedArticle; |
1746 | 1730 | # Assume $action may still not be set, in which case, treat it as 'view'... |
1747 | 1731 | if( $action != 'read' ) |
1748 | 1732 | return true; |
— | — | @@ -1757,7 +1741,7 @@ |
1758 | 1742 | } |
1759 | 1743 | # See if there is a stable version. Also, see if, given the page |
1760 | 1744 | # config and URL params, the page can be overriden. |
1761 | | - if( $wgTitle && $wgTitle->equals( $title ) ) { |
| 1745 | + if( $wgFlaggedArticle && $wgTitle && $wgTitle->equals( $title ) ) { |
1762 | 1746 | global $wgFlaggedArticle; |
1763 | 1747 | // Cache stable version while we are at it. |
1764 | 1748 | if( $wgFlaggedArticle->pageOverride() && $wgFlaggedArticle->getStableRev( true ) ) { |
— | — | @@ -1772,42 +1756,89 @@ |
1773 | 1757 | } |
1774 | 1758 | |
1775 | 1759 | /** |
1776 | | - * When a null edit is made, autoreview if necessary |
| 1760 | + * When an edit is made by a reviewer, if the current revision is the stable |
| 1761 | + * version, try to automatically review it. |
1777 | 1762 | */ |
1778 | | - public static function maybeMakeNullEditReviewed( $rev ) { |
1779 | | - $title = $rev->getTitle(); |
| 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; |
1780 | 1769 | # GetTitle() for revisions uses slaves and wants page_id,rev_id to |
1781 | 1770 | # match...this is bad if we *just* added it. |
1782 | | - $title = $title ? $title : Title::newFromID( $rev->getPage() ); |
| 1771 | + $title = $rev->getTitle() ? $rev->getTitle() : Title::newFromID( $rev->getPage(), GAID_FOR_UPDATE ); |
| 1772 | + # Must be in reviewable namespace |
1783 | 1773 | if( !$title || !self::isPageReviewable( $title ) ) { |
1784 | 1774 | return true; |
1785 | 1775 | } |
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 | | - } |
| 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; |
1803 | 1794 | } |
1804 | | - $user = User::newFromId( $rev->getUser() ); |
1805 | | - FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags ); |
1806 | 1795 | } |
| 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 | + } |
1807 | 1805 | } |
| 1806 | + if( $wgFlaggedArticle ) { |
| 1807 | + $wgFlaggedArticle->skipReviewDiff = true; // Don't jump to diff... |
| 1808 | + } |
1808 | 1809 | return true; |
1809 | 1810 | } |
1810 | 1811 | |
1811 | 1812 | /** |
| 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 | + /** |
1812 | 1843 | * When an edit is made to a page that can't be reviewed, autopatrol if allowed. |
1813 | 1844 | * This is not loggged for perfomance reasons and no one cares if talk pages and such |
1814 | 1845 | * are autopatrolled. |
— | — | @@ -2114,46 +2145,8 @@ |
2115 | 2146 | * Add user preference to form HTML |
2116 | 2147 | */ |
2117 | 2148 | public static function injectPreferences( $form, $out ) { |
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 | | - |
| 2149 | + $prefsHtml = FlaggedRevsXML::stabilityPreferences( $form ); |
| 2150 | + $out->addHTML( $prefsHtml ); |
2158 | 2151 | return true; |
2159 | 2152 | } |
2160 | 2153 | |
— | — | @@ -2213,4 +2206,21 @@ |
2214 | 2207 | } |
2215 | 2208 | } |
2216 | 2209 | |
| 2210 | +function efFlaggedRevsSchemaUpdates() { |
| 2211 | + global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables; |
2217 | 2212 | |
| 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,8 +117,12 @@ |
118 | 118 | $msg = $quality ? 'revreview-quality-old' : 'revreview-basic-old'; |
119 | 119 | $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time ); |
120 | 120 | } else { |
121 | | - $msg = $stable ? 'revreview-' : 'revreview-newest-'; |
122 | | - $msg .= $quality ? 'quality' : 'basic'; |
| 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 | + } |
123 | 127 | $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time, $revs_since ); |
124 | 128 | } |
125 | 129 | # Make fancy box... |
— | — | @@ -137,4 +141,45 @@ |
138 | 142 | |
139 | 143 | return $box; |
140 | 144 | } |
| 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 | + } |
141 | 186 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -1,9 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class FlaggedArticle { |
| 4 | +class FlaggedArticle extends Article { |
5 | 5 | public $isDiffFromStable = false; |
6 | 6 | public $skipReviewDiff = false; |
7 | | - public $skipAutoReview = false; |
8 | 7 | public $stableRev = null; |
9 | 8 | public $pageconfig = null; |
10 | 9 | public $flags = null; |
— | — | @@ -75,9 +74,7 @@ |
76 | 75 | * Is this article reviewable? |
77 | 76 | */ |
78 | 77 | public function isReviewable() { |
79 | | - global $wgTitle; |
80 | | - |
81 | | - return FlaggedRevs::isPageReviewable( $wgTitle ); |
| 78 | + return FlaggedRevs::isPageReviewable( $this->getTitle() ); |
82 | 79 | } |
83 | 80 | |
84 | 81 | /** |
— | — | @@ -85,12 +82,7 @@ |
86 | 83 | */ |
87 | 84 | private function displayTag() { |
88 | 85 | global $wgOut; |
89 | | - |
90 | | - if( !$this->reviewNotice ) { |
91 | | - return false; |
92 | | - } |
93 | 86 | $wgOut->appendSubtitle( $this->reviewNotice ); |
94 | | - |
95 | 87 | return true; |
96 | 88 | } |
97 | 89 | |
— | — | @@ -176,13 +168,7 @@ |
177 | 169 | // behavior below, since it is the same as ("&stable=1"). |
178 | 170 | if( $old ) { |
179 | 171 | $revs_since = FlaggedRevs::getRevCountSince( $article, $frev->getRevId() ); |
180 | | - global $wgUseStableTemplates; |
181 | | - if( $wgUseStableTemplates ) { |
182 | | - $rev = Revision::newFromId( $frev->getRevId() ); |
183 | | - $text = $rev->getText(); |
184 | | - } else { |
185 | | - $text = $frev->getExpandedText(); |
186 | | - } |
| 172 | + $text = $frev->getTextForParse(); |
187 | 173 | $parserOut = FlaggedRevs::parseStableText( $article, $text, $frev->getRevId() ); |
188 | 174 | # Construct some tagging for non-printable outputs. Note that the pending |
189 | 175 | # notice has all this info already, so don't do this if we added that already. |
— | — | @@ -286,13 +272,7 @@ |
287 | 273 | # Get parsed stable version |
288 | 274 | $parserOut = FlaggedRevs::getPageCache( $article ); |
289 | 275 | if( $parserOut==false ) { |
290 | | - global $wgUseStableTemplates; |
291 | | - if( $wgUseStableTemplates ) { |
292 | | - $rev = Revision::newFromId( $frev->getRevId() ); |
293 | | - $text = $rev->getText(); |
294 | | - } else { |
295 | | - $text = $frev->getExpandedText(); |
296 | | - } |
| 276 | + $text = $frev->getTextForParse(); |
297 | 277 | $parserOut = FlaggedRevs::parseStableText( $article, $text, $frev->getRevId() ); |
298 | 278 | # Update the stable version cache |
299 | 279 | FlaggedRevs::updatePageCache( $article, $parserOut ); |
— | — | @@ -314,6 +294,7 @@ |
315 | 295 | // Standard UI |
316 | 296 | } else { |
317 | 297 | $msg = $quality ? 'revreview-quality' : 'revreview-basic'; |
| 298 | + $msg .= ($revs_since == 0) ? '-i' : ''; |
318 | 299 | $msg = $synced ? "{$msg}-same" : $msg; |
319 | 300 | |
320 | 301 | $tag = "<span class='{$css} plainlinks' title=\"{$tooltip}\"></span>" . |
— | — | @@ -405,7 +386,7 @@ |
406 | 387 | * Adds latest stable version tag to page when editing |
407 | 388 | */ |
408 | 389 | public function addToEditView( $editform ) { |
409 | | - global $wgRequest, $wgTitle, $wgOut; |
| 390 | + global $wgRequest, $wgOut; |
410 | 391 | # Talk pages cannot be validated |
411 | 392 | if( !$editform->mArticle || !$this->isReviewable() ) |
412 | 393 | return false; |
— | — | @@ -422,7 +403,7 @@ |
423 | 404 | $tag = $warning = ''; |
424 | 405 | # Check the newest stable version |
425 | 406 | $frev = $this->getStableRev(); |
426 | | - if( !is_null($frev) && $frev->getRevId() != $revid ) { |
| 407 | + if( !is_null($frev) ) { |
427 | 408 | global $wgLang, $wgUser, $wgFlaggedRevsAutoReview; |
428 | 409 | |
429 | 410 | $time = $wgLang->date( $frev->getTimestamp(), true ); |
— | — | @@ -441,26 +422,28 @@ |
442 | 423 | wfMsgExt($msg,array('parseinline')) . "</div>"; |
443 | 424 | } |
444 | 425 | } |
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>'; |
| 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>"; |
463 | 447 | } |
464 | | - $tag = "<div id='mw-revisiontag-edit' class='flaggedrevs_editnotice plainlinks'>$tag</div>"; |
465 | 448 | } |
466 | 449 | $wgOut->addHTML( $tag . $warning ); |
467 | 450 | # Show diff to stable, to make things less confusing |
— | — | @@ -536,7 +519,7 @@ |
537 | 520 | * Add link to stable version setting to protection form |
538 | 521 | */ |
539 | 522 | public function addVisibilityLink( $out ) { |
540 | | - global $wgUser, $wgRequest, $wgTitle; |
| 523 | + global $wgUser, $wgRequest; |
541 | 524 | |
542 | 525 | if( !$this->isReviewable() ) |
543 | 526 | return true; |
— | — | @@ -906,108 +889,6 @@ |
907 | 890 | |
908 | 891 | return true; |
909 | 892 | } |
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 | | - } |
1012 | 893 | |
1013 | 894 | /** |
1014 | 895 | * Add a hidden revision ID field to edit form. |
— | — | @@ -1047,8 +928,7 @@ |
1048 | 929 | return $this->stableRev; |
1049 | 930 | } |
1050 | 931 | # Get the content page, skip talk |
1051 | | - global $wgTitle; |
1052 | | - $title = $wgTitle->getSubjectPage(); |
| 932 | + $title = $this->getTitle()->getSubjectPage(); |
1053 | 933 | # Do we have one? |
1054 | 934 | $srev = FlaggedRevs::getStablePageRev( $title, $getText, $forUpdate ); |
1055 | 935 | if( $srev ) { |
— | — | @@ -1066,13 +946,12 @@ |
1067 | 947 | * @returns Array (select,override) |
1068 | 948 | */ |
1069 | 949 | public function getVisibilitySettings( $forUpdate=false ) { |
1070 | | - global $wgTitle; |
1071 | 950 | # Cached results available? |
1072 | 951 | if( !is_null($this->pageconfig) ) { |
1073 | 952 | return $this->pageconfig; |
1074 | 953 | } |
1075 | 954 | # Get the content page, skip talk |
1076 | | - $title = $wgTitle->getSubjectPage(); |
| 955 | + $title = $this->getTitle()->getSubjectPage(); |
1077 | 956 | |
1078 | 957 | $config = FlaggedRevs::getPageVisibilitySettings( $title, $forUpdate ); |
1079 | 958 | $this->pageconfig = $config; |
— | — | @@ -1085,12 +964,12 @@ |
1086 | 965 | * @eturns Array, output of the flags for a given revision |
1087 | 966 | */ |
1088 | 967 | public function getFlagsForRevision( $rev_id ) { |
1089 | | - global $wgFlaggedRevTags, $wgTitle; |
| 968 | + global $wgFlaggedRevTags; |
1090 | 969 | # Cached results? |
1091 | 970 | if( isset($this->flags[$rev_id]) && $this->flags[$rev_id] ) |
1092 | 971 | return $this->flags[$rev_id]; |
1093 | 972 | # Get the flags |
1094 | | - $flags = FlaggedRevs::getRevisionTags( $wgTitle, $rev_id ); |
| 973 | + $flags = FlaggedRevs::getRevisionTags( $this->getTitle(), $rev_id ); |
1095 | 974 | # Try to cache results |
1096 | 975 | $this->flags[$rev_id] = $flags; |
1097 | 976 | |
— | — | @@ -1104,7 +983,7 @@ |
1105 | 984 | * @param bool $top, should this form always go on top? |
1106 | 985 | */ |
1107 | 986 | public function addQuickReview( $out, $top = false ) { |
1108 | | - global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgFlaggedRevComments, $wgFlaggedRevsOverride; |
| 987 | + global $wgOut, $wgUser, $wgRequest, $wgFlaggedRevComments, $wgFlaggedRevsOverride; |
1109 | 988 | # User must have review rights |
1110 | 989 | if( !$wgUser->isAllowed( 'review' ) ) { |
1111 | 990 | return; |
— | — | @@ -1233,16 +1112,16 @@ |
1234 | 1113 | } |
1235 | 1114 | } |
1236 | 1115 | # For image pages, note the current image version |
1237 | | - if( $wgTitle->getNamespace() == NS_IMAGE ) { |
1238 | | - $file = wfFindFile( $wgTitle ); |
| 1116 | + if( $this->getTitle()->getNamespace() == NS_IMAGE ) { |
| 1117 | + $file = wfFindFile( $this->getTitle() ); |
1239 | 1118 | if( $file ) { |
1240 | | - $imageParams .= $wgTitle->getDBkey() . "|" . $file->getTimestamp() . "|" . $file->getSha1() . "#"; |
| 1119 | + $imageParams .= $this->getTitle()->getDBkey() . "|" . $file->getTimestamp() . "|" . $file->getSha1() . "#"; |
1241 | 1120 | } |
1242 | 1121 | } |
1243 | 1122 | |
1244 | 1123 | # Hidden params |
1245 | 1124 | $form .= Xml::hidden( 'title', $reviewtitle->getPrefixedText() ) . "\n"; |
1246 | | - $form .= Xml::hidden( 'target', $wgTitle->getPrefixedText() ) . "\n"; |
| 1125 | + $form .= Xml::hidden( 'target', $this->getTitle()->getPrefixedText() ) . "\n"; |
1247 | 1126 | $form .= Xml::hidden( 'oldid', $id ) . "\n"; |
1248 | 1127 | $form .= Xml::hidden( 'action', 'submit') . "\n"; |
1249 | 1128 | $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n"; |
— | — | @@ -1310,11 +1189,18 @@ |
1311 | 1190 | * If viewing a stable version, adjust the last modified header |
1312 | 1191 | */ |
1313 | 1192 | public function setLastModified( $sktmp, &$tpl ) { |
1314 | | - global $wgArticle, $wgLang; |
| 1193 | + global $wgArticle, $wgLang, $wgRequest; |
1315 | 1194 | # Non-content pages cannot be validated |
1316 | | - if( !$this->pageOverride() ) |
| 1195 | + if( !$this->isReviewable() ) |
1317 | 1196 | return true; |
| 1197 | + # Old stable versions |
| 1198 | + if( $wgRequest->getIntOrNull('stableid') ) { |
| 1199 | + $tpl->set('lastmod', false); |
| 1200 | + return true; |
| 1201 | + } |
1318 | 1202 | # Check for an overridabe revision |
| 1203 | + if( !$this->pageOverride() ) |
| 1204 | + return true; |
1319 | 1205 | $frev = $this->getStableRev( true ); |
1320 | 1206 | if( !$frev || $frev->getRevId() == $wgArticle->getLatest() ) |
1321 | 1207 | return true; |
— | — | @@ -1359,5 +1245,3 @@ |
1360 | 1246 | return true; |
1361 | 1247 | } |
1362 | 1248 | } |
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|changes}}] await review.", |
| 45 | +The ''draft'' is shown below.''' [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} $2 {{plural:$2|change awaits|changes await}}] review.", |
46 | 46 | |
47 | 47 | 'validationpage' => '{{ns:help}}:Article validation', |
48 | 48 | |
— | — | @@ -66,6 +66,10 @@ |
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.', |
70 | 74 | '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>.', |
71 | 75 | '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>.', |
72 | 76 | '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.12+ |
| 9 | +* Upgrade to MediaWiki 1.13+ |
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,7 +594,9 @@ |
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 | | - $parserCache->save( $poutput, $article, $wgUser ); |
| 598 | + global $wgEnableParserCache; |
| 599 | + if( $wgEnableParserCache ) |
| 600 | + $parserCache->save( $poutput, $article, $wgUser ); |
599 | 601 | # Purge squid for this page only |
600 | 602 | $article->getTitle()->purgeSquid(); |
601 | 603 | |
— | — | @@ -646,7 +648,9 @@ |
647 | 649 | # Clear the cache... |
648 | 650 | $this->page->invalidateCache(); |
649 | 651 | # Might as well save the cache |
650 | | - $parserCache->save( $poutput, $article, $wgUser ); |
| 652 | + global $wgEnableParserCache; |
| 653 | + if( $wgEnableParserCache ) |
| 654 | + $parserCache->save( $poutput, $article, $wgUser ); |
651 | 655 | # Purge squid for this page only |
652 | 656 | $this->page->purgeSquid(); |
653 | 657 | |
— | — | @@ -897,15 +901,17 @@ |
898 | 902 | ' ' . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" . |
899 | 903 | "</fieldset></form>" |
900 | 904 | ); |
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') ) ); |
| 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 | + } |
910 | 916 | } |
911 | 917 | } |
912 | 918 | |
— | — | @@ -945,6 +951,22 @@ |
946 | 952 | array( 'LIMIT' => 5 ) ); |
947 | 953 | return $res->numRows(); |
948 | 954 | } |
| 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 | + } |
949 | 971 | } |
950 | 972 | |
951 | 973 | /** |
— | — | @@ -977,7 +999,6 @@ |
978 | 1000 | |
979 | 1001 | function getQueryInfo() { |
980 | 1002 | $conds = $this->mConds; |
981 | | - $tables = array( 'page', 'flaggedpages' ); |
982 | 1003 | $fields = array('page_namespace','page_title','page_len','fp_stable'); |
983 | 1004 | $conds[] = 'fp_reviewed IS NULL'; |
984 | 1005 | # Reviewable pages only |
— | — | @@ -986,69 +1007,26 @@ |
987 | 1008 | $conds['page_is_redirect'] = 0; |
988 | 1009 | # Filter by category |
989 | 1010 | if( $this->category ) { |
990 | | - $tables[] = 'categorylinks'; |
| 1011 | + $tables = array( 'categorylinks', 'page', 'flaggedpages' ); |
991 | 1012 | $fields[] = 'cl_sortkey'; |
992 | 1013 | $conds['cl_to'] = $this->category; |
993 | 1014 | $conds[] = 'cl_from = page_id'; |
994 | 1015 | $this->mIndexField = 'cl_sortkey'; |
| 1016 | + $useIndex = array( 'categorylinks' => 'cl_sortkey' ); |
995 | 1017 | } else { |
| 1018 | + $tables = array( 'page', 'flaggedpages' ); |
996 | 1019 | $fields[] = 'page_id'; |
997 | 1020 | $this->mIndexField = 'page_title'; |
| 1021 | + $useIndex = array( 'page' => 'name_title' ); |
998 | 1022 | } |
999 | 1023 | return array( |
1000 | 1024 | 'tables' => $tables, |
1001 | 1025 | 'fields' => $fields, |
1002 | 1026 | 'conds' => $conds, |
1003 | | - 'options' => array() |
| 1027 | + 'options' => array( 'USE INDEX' => $useIndex ), |
| 1028 | + 'join_conds' => array( 'flaggedpages' => array('LEFT JOIN','fp_page_id=page_id') ) |
1004 | 1029 | ); |
1005 | 1030 | } |
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 | | - } |
1053 | 1031 | |
1054 | 1032 | function getIndexField() { |
1055 | 1033 | return $this->mIndexField; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -101,6 +101,13 @@ |
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 | + } |
105 | 112 | |
106 | 113 | /** |
107 | 114 | * @returns Integer revision timestamp in MW format |
— | — | @@ -123,12 +130,20 @@ |
124 | 131 | $this->loadText(); // load if not loaded |
125 | 132 | return $this->mText; |
126 | 133 | } |
127 | | - |
| 134 | + |
128 | 135 | /** |
129 | | - * @returns Integer the user ID of the reviewer |
| 136 | + * @returns mixed (string/false) expanded text or revision text. |
| 137 | + * Depends on whether $wgUseStableTemplates is on or not. |
130 | 138 | */ |
131 | | - public function getUser() { |
132 | | - return $this->mUser; |
| 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; |
133 | 148 | } |
134 | 149 | |
135 | 150 | /** |