Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -143,12 +143,12 @@ |
144 | 144 | |
145 | 145 | # Define when users get automatically promoted to editors. Set as false to disable. |
146 | 146 | $wgFlaggedRevsAutopromote = array( |
147 | | - 'days' => 60, |
148 | | - 'edits' => 200, |
149 | | - 'spacing' => 5, |
| 147 | + 'days' => 60, |
| 148 | + 'edits' => 200, |
| 149 | + 'spacing' => 5, |
150 | 150 | 'benchmarks' => 5, // keep this small |
151 | | - 'email' => true, |
152 | | - 'userpage' => true |
| 151 | + 'email' => true, |
| 152 | + 'userpage' => true |
153 | 153 | ); |
154 | 154 | |
155 | 155 | # Variables below this point should probably not be modified |
— | — | @@ -200,11 +200,11 @@ |
201 | 201 | /** |
202 | 202 | * @param string $text |
203 | 203 | * @param Title $title |
204 | | - * @param Integer $id, revision id |
| 204 | + * @param integer $id, revision id |
205 | 205 | * @returns array( string, bool ) |
206 | 206 | * All included pages/arguments are expanded out |
207 | 207 | */ |
208 | | - public static function expandText( $text='', $title, $id=null ) { |
| 208 | + public function expandText( $text='', $title, $id=null ) { |
209 | 209 | global $wgParser, $wgUser; |
210 | 210 | # Make our hooks to trigger |
211 | 211 | $wgParser->isStable = true; |
— | — | @@ -228,7 +228,7 @@ |
229 | 229 | * @returns ParserOutput |
230 | 230 | * Get the HTML of a revision based on how it was during $timeframe |
231 | 231 | */ |
232 | | - public static function parseStableText( $article, $text, $id=NULL ) { |
| 232 | + public function parseStableText( $article, $text, $id=NULL ) { |
233 | 233 | global $wgParser, $wgUser; |
234 | 234 | # Default options for anons if not logged in |
235 | 235 | $options = ParserOptions::newFromUser($wgUser); |
— | — | @@ -251,7 +251,7 @@ |
252 | 252 | * @returns string, flags |
253 | 253 | * Compress pre-processed text, passed by reference |
254 | 254 | */ |
255 | | - public static function compressText( &$text ) { |
| 255 | + public function compressText( &$text ) { |
256 | 256 | global $wgFlaggedRevsCompression; |
257 | 257 | # Compress text if $wgFlaggedRevsCompression is set. |
258 | 258 | $flags = array( 'utf-8' ); |
— | — | @@ -272,7 +272,7 @@ |
273 | 273 | * @returns string |
274 | 274 | * Uncompress pre-processed text, using flags |
275 | 275 | */ |
276 | | - public static function uncompressText( $text, $flags ) { |
| 276 | + public function uncompressText( $text, $flags ) { |
277 | 277 | global $wgFlaggedRevsCompression; |
278 | 278 | |
279 | 279 | if( !is_array($flags) ) { |
— | — | @@ -294,15 +294,16 @@ |
295 | 295 | * @returns string |
296 | 296 | * Get the text of a stable version |
297 | 297 | */ |
298 | | - public static function getFlaggedRevText( $rev_id ) { |
299 | | - $db = wfGetDB( DB_SLAVE ); |
| 298 | + public function getFlaggedRevText( $rev_id ) { |
| 299 | + $dbr = wfGetDB( DB_SLAVE ); |
300 | 300 | // Get the text from the flagged revisions table |
301 | | - $result = $db->select( array('flaggedrevs','revision'), |
| 301 | + $result = $dbr->select( array('flaggedrevs','revision'), |
302 | 302 | array('fr_text', 'fr_flags'), |
303 | | - array('fr_rev_id' => $rev_id, 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
| 303 | + array('fr_rev_id' => $rev_id, 'fr_rev_id = rev_id', |
| 304 | + 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
304 | 305 | __METHOD__, |
305 | 306 | array('LIMIT' => 1) ); |
306 | | - if( $row = $db->fetchObject($result) ) { |
| 307 | + if( $row = $dbr->fetchObject($result) ) { |
307 | 308 | return self::uncompressText( $row->fr_text, $row->fr_flags ); |
308 | 309 | } |
309 | 310 | |
— | — | @@ -314,15 +315,16 @@ |
315 | 316 | * @returns Revision |
316 | 317 | * Will not return if deleted |
317 | 318 | */ |
318 | | - public static function getFlaggedRev( $rev_id ) { |
319 | | - $db = wfGetDB( DB_SLAVE ); |
320 | | - // Skip deleted revisions |
321 | | - $result = $db->select( array('flaggedrevs','revision'), |
| 319 | + public function getFlaggedRev( $rev_id ) { |
| 320 | + $dbr = wfGetDB( DB_SLAVE ); |
| 321 | + # Skip deleted revisions |
| 322 | + $result = $dbr->select( array('flaggedrevs','revision'), |
322 | 323 | array('fr_namespace', 'fr_title', 'fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
323 | | - array('fr_rev_id' => $rev_id, 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
| 324 | + array('fr_rev_id' => $rev_id, 'fr_rev_id = rev_id', |
| 325 | + 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
324 | 326 | __METHOD__ ); |
325 | | - // Sorted from highest to lowest, so just take the first one if any |
326 | | - if( $row = $db->fetchObject($result) ) { |
| 327 | + # Sorted from highest to lowest, so just take the first one if any |
| 328 | + if( $row = $dbr->fetchObject($result) ) { |
327 | 329 | return $row; |
328 | 330 | } |
329 | 331 | |
— | — | @@ -335,16 +337,16 @@ |
336 | 338 | * Get rev ids of reviewed revs for a page |
337 | 339 | * Will include deleted revs here |
338 | 340 | */ |
339 | | - public static function getReviewedRevs( $page ) { |
| 341 | + public function getReviewedRevs( $page ) { |
340 | 342 | $rows = array(); |
341 | 343 | |
342 | | - $db = wfGetDB( DB_SLAVE ); |
343 | | - $result = $db->select('flaggedrevs', |
| 344 | + $dbr = wfGetDB( DB_SLAVE ); |
| 345 | + $result = $dbr->select('flaggedrevs', |
344 | 346 | array('fr_rev_id','fr_quality'), |
345 | 347 | array('fr_namespace' => $page->getNamespace(), 'fr_title' => $page->getDBkey() ), |
346 | 348 | __METHOD__ , |
347 | 349 | array('ORDER BY' => 'fr_rev_id DESC') ); |
348 | | - while( $row = $db->fetchObject($result) ) { |
| 350 | + while( $row = $dbr->fetchObject($result) ) { |
349 | 351 | $rows[$row->fr_rev_id] = $row->fr_quality; |
350 | 352 | } |
351 | 353 | |
— | — | @@ -357,7 +359,7 @@ |
358 | 360 | * @returns int |
359 | 361 | * Get number of revs since a certain revision |
360 | 362 | */ |
361 | | - public static function getRevCountSince( $page_id, $from_rev ) { |
| 363 | + public function getRevCountSince( $page_id, $from_rev ) { |
362 | 364 | $dbr = wfGetDB( DB_SLAVE ); |
363 | 365 | $count = $dbr->selectField('revision', 'COUNT(*)', |
364 | 366 | array('rev_page' => $page_id, "rev_id > $from_rev"), |
— | — | @@ -382,10 +384,9 @@ |
383 | 385 | $selectColumns[] = 'fr_text'; |
384 | 386 | $selectColumns[] = 'fr_flags'; |
385 | 387 | } |
386 | | - |
| 388 | + # If we want the text, then get the text flags too |
387 | 389 | if( !$forUpdate ) { |
388 | 390 | $dbr = wfGetDB( DB_SLAVE ); |
389 | | - // Skip deleted revisions |
390 | 391 | $result = $dbr->select( array('page', 'flaggedrevs', 'revision'), |
391 | 392 | $selectColumns, |
392 | 393 | array('page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), |
— | — | @@ -403,8 +404,8 @@ |
404 | 405 | // Look for quality revision |
405 | 406 | $result = $dbw->select( array('flaggedrevs', 'revision'), |
406 | 407 | $selectColumns, |
407 | | - array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), 'fr_quality >= 1', |
408 | | - 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
| 408 | + array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), |
| 409 | + 'fr_quality >= 1', 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
409 | 410 | __METHOD__, |
410 | 411 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
411 | 412 | // Do we have one? If not, try any reviewed revision... |
— | — | @@ -412,7 +413,7 @@ |
413 | 414 | $result = $dbw->select( array('flaggedrevs', 'revision'), |
414 | 415 | $selectColumns, |
415 | 416 | array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), |
416 | | - 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
| 417 | + 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
417 | 418 | __METHOD__, |
418 | 419 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
419 | 420 | if( !$row = $dbw->fetchObject($result) ) |
— | — | @@ -427,19 +428,18 @@ |
428 | 429 | * @returns Array |
429 | 430 | */ |
430 | 431 | public function getFlagsForRevision( $rev_id ) { |
431 | | - // Set all flags to zero |
| 432 | + # Set all flags to zero |
432 | 433 | $flags = array(); |
433 | 434 | foreach( array_keys($this->dimensions) as $tag ) { |
434 | 435 | $flags[$tag] = 0; |
435 | 436 | } |
436 | | - |
| 437 | + # Grab all the tags for this revision |
437 | 438 | $db = wfGetDB( DB_SLAVE ); |
438 | | - // Grab all the tags for this revision |
439 | 439 | $result = $db->select('flaggedrevtags', |
440 | 440 | array('frt_dimension', 'frt_value'), |
441 | 441 | array('frt_rev_id' => $rev_id), |
442 | 442 | __METHOD__ ); |
443 | | - // Iterate through each tag result |
| 443 | + # Iterate through each tag result |
444 | 444 | while ( $row = $db->fetchObject($result) ) { |
445 | 445 | $flags[$row->frt_dimension] = $row->frt_value; |
446 | 446 | } |
— | — | @@ -451,7 +451,7 @@ |
452 | 452 | * @returns bool |
453 | 453 | * Is $title the main page? |
454 | 454 | */ |
455 | | - public static function isMainPage( $title ) { |
| 455 | + public function isMainPage( $title ) { |
456 | 456 | $mp = Title::newMainPage(); |
457 | 457 | return ( $title->getNamespace()==$mp->getNamespace() && $title->getDBKey()==$mp->getDBKey() ); |
458 | 458 | } |
— | — | @@ -459,7 +459,7 @@ |
460 | 460 | /** |
461 | 461 | * @param array $flags |
462 | 462 | * @param bool $prettybox |
463 | | - * @param string $css |
| 463 | + * @param string $css, class to wrap box in |
464 | 464 | * @returns string |
465 | 465 | * Generates a review box/tag |
466 | 466 | */ |
— | — | @@ -512,14 +512,14 @@ |
513 | 513 | $quality = self::isQuality( $flags ); |
514 | 514 | $pristine = self::isPristine( $flags ); |
515 | 515 | $time = $wgLang->date( wfTimestamp(TS_MW, $tfrev->fr_timestamp), true ); |
516 | | - // Some checks for which tag CSS to use |
| 516 | + # Some checks for which tag CSS to use |
517 | 517 | if( $pristine ) |
518 | 518 | $tagClass = 'flaggedrevs_box3'; |
519 | 519 | else if( $quality ) |
520 | 520 | $tagClass = 'flaggedrevs_box2'; |
521 | 521 | else |
522 | 522 | $tagClass = 'flaggedrevs_box1'; |
523 | | - // Construct some tagging |
| 523 | + # Construct some tagging |
524 | 524 | $msg = $stable ? 'revreview-' : 'revreview-newest-'; |
525 | 525 | $msg .= $quality ? 'quality' : 'basic'; |
526 | 526 | $msg2 = $stable ? '' : ' '.wfMsg('revreview-oldrating'); |
— | — | @@ -540,7 +540,7 @@ |
541 | 541 | * @returns string |
542 | 542 | * Generates revision review notes |
543 | 543 | */ |
544 | | - public static function ReviewNotes( $row ) { |
| 544 | + public function ReviewNotes( $row ) { |
545 | 545 | global $wgUser, $wgFlaggedRevComments; |
546 | 546 | |
547 | 547 | if( !$row || !$wgFlaggedRevComments ) |
— | — | @@ -559,7 +559,7 @@ |
560 | 560 | * @param Array $flags |
561 | 561 | * @returns bool, is this revision at quality condition? |
562 | 562 | */ |
563 | | - public static function isQuality( $flags ) { |
| 563 | + public function isQuality( $flags ) { |
564 | 564 | global $wgFlaggedRevTags; |
565 | 565 | |
566 | 566 | foreach( $wgFlaggedRevTags as $f => $v ) { |
— | — | @@ -573,7 +573,7 @@ |
574 | 574 | * @param Array $flags |
575 | 575 | * @returns bool, is this revision at optimal condition? |
576 | 576 | */ |
577 | | - public static function isPristine( $flags ) { |
| 577 | + public function isPristine( $flags ) { |
578 | 578 | global $wgFlaggedRevTags, $wgFlaggedRevValues; |
579 | 579 | |
580 | 580 | foreach( $wgFlaggedRevTags as $f => $v ) { |
— | — | @@ -588,31 +588,28 @@ |
589 | 589 | * @param Title, $title |
590 | 590 | * @returns bool |
591 | 591 | */ |
592 | | - public static function isReviewable( $title ) { |
| 592 | + public function isReviewable( $title ) { |
593 | 593 | global $wgFlaggedRevsNamespaces; |
594 | 594 | |
595 | 595 | return in_array($title->getNamespace(),$wgFlaggedRevsNamespaces); |
596 | 596 | } |
597 | 597 | |
598 | | - ######### Hooked functions ######### |
599 | | - |
600 | 598 | /** |
601 | 599 | * @param Article $article |
602 | 600 | * @returns ParserOutput |
603 | 601 | * Get the page cache for the top stable revision of an article |
604 | 602 | */ |
605 | | - public static function getPageCache( $article ) { |
| 603 | + public function getPageCache( $article ) { |
606 | 604 | global $wgUser, $parserMemc, $wgCacheEpoch, $wgFlaggedRevsExpire; |
607 | 605 | |
608 | | - $fname = 'FlaggedRevs::getPageCache'; |
609 | | - wfProfileIn( $fname ); |
610 | | - |
611 | | - // Make sure it is valid |
612 | | - if( !$article || !$article->getId() ) return NULL; |
| 606 | + wfProfileIn( __METHOD__ ); |
| 607 | + # Make sure it is valid |
| 608 | + if( !$article || !$article->getId() ) |
| 609 | + return NULL; |
613 | 610 | |
614 | 611 | $parserCache =& ParserCache::singleton(); |
615 | 612 | $key = 'sv-' . $parserCache->getKey( $article, $wgUser ); |
616 | | - // Get the cached HTML |
| 613 | + # Get the cached HTML |
617 | 614 | wfDebug( "Trying parser cache $key\n" ); |
618 | 615 | $value = $parserMemc->get( $key ); |
619 | 616 | if( is_object( $value ) ) { |
— | — | @@ -653,38 +650,153 @@ |
654 | 651 | * @param parerOutput $parserOut |
655 | 652 | * Updates the stable cache of a page with the given $parserOut |
656 | 653 | */ |
657 | | - public static function updatePageCache( $article, $parserOut=NULL ) { |
| 654 | + public function updatePageCache( $article, $parserOut=NULL ) { |
658 | 655 | global $wgUser, $parserMemc, $wgFlaggedRevsExpire; |
659 | | - // Make sure it is valid |
660 | | - if( is_null($parserOut) || !$article ) return false; |
661 | | - |
662 | | - // Update the cache... |
| 656 | + # Make sure it is valid |
| 657 | + if( is_null($parserOut) || !$article ) |
| 658 | + return false; |
| 659 | + # Update the cache... |
663 | 660 | $article->mTitle->invalidateCache(); |
664 | 661 | |
665 | 662 | $parserCache =& ParserCache::singleton(); |
666 | 663 | $key = 'sv-' . $parserCache->getKey( $article, $wgUser ); |
667 | | - // Add cache mark to HTML |
| 664 | + # Add cache mark to HTML |
668 | 665 | $now = wfTimestampNow(); |
669 | 666 | $parserOut->setCacheTime( $now ); |
670 | | - |
671 | | - // Save the timestamp so that we don't have to load the revision row on view |
| 667 | + # Save the timestamp so that we don't have to load the revision row on view |
672 | 668 | $parserOut->mTimestamp = $article->getTimestamp(); |
673 | | - |
674 | 669 | $parserOut->mText .= "\n<!-- Saved in stable version parser cache with key $key and timestamp $now -->"; |
675 | | - // Set expire time |
| 670 | + # Set expire time |
676 | 671 | if( $parserOut->containsOldMagic() ){ |
677 | 672 | $expire = 3600; # 1 hour |
678 | 673 | } else { |
679 | 674 | $expire = $wgFlaggedRevsExpire; |
680 | 675 | } |
681 | | - // Save to objectcache |
| 676 | + # Save to objectcache |
682 | 677 | $parserMemc->set( $key, $parserOut, $expire ); |
683 | | - // Purge squid for this page only |
| 678 | + # Purge squid for this page only |
684 | 679 | $article->mTitle->purgeSquid(); |
685 | 680 | |
686 | 681 | return true; |
687 | 682 | } |
688 | 683 | |
| 684 | + /** |
| 685 | + * Automatically review an edit and add a log entry in the review log. |
| 686 | + * LinksUpdate was already called via edit operations, so the page |
| 687 | + * fields will be up to date. This updates the stable version. |
| 688 | + */ |
| 689 | + public function autoReviewEdit( $article, $user, $text, $rev, $flags ) { |
| 690 | + global $wgParser, $wgFlaggedRevsAutoReview, $wgFlaggedRevs; |
| 691 | + |
| 692 | + $quality = 0; |
| 693 | + if( $wgFlaggedRevs->isQuality($flags) ) { |
| 694 | + $quality = $wgFlaggedRevs->isPristine($flags) ? 2 : 1; |
| 695 | + } |
| 696 | + $flagset = $tmpset = $imgset = array(); |
| 697 | + foreach( $flags as $tag => $value ) { |
| 698 | + $flagset[] = array( |
| 699 | + 'frt_rev_id' => $rev->getId(), |
| 700 | + 'frt_dimension' => $tag, |
| 701 | + 'frt_value' => $value |
| 702 | + ); |
| 703 | + } |
| 704 | + # Try the parser cache, should be set on the edit before this is called. |
| 705 | + # If not set or up to date, then parse it... |
| 706 | + $parserCache =& ParserCache::singleton(); |
| 707 | + $poutput = $parserCache->get( $article, $user ); |
| 708 | + if( $poutput==false ) { |
| 709 | + $options = ParserOptions::newFromUser($user); |
| 710 | + $options->setTidy(true); |
| 711 | + $poutput = $wgParser->parse( $text, $article->mTitle, $options, true, true, $rev->getID() ); |
| 712 | + # Might as well save the cache while we're at it |
| 713 | + $parserCache->save( $poutput, $article, $user ); |
| 714 | + } |
| 715 | + # NS:title -> rev ID mapping |
| 716 | + foreach( $poutput->mTemplateIds as $namespace => $title ) { |
| 717 | + foreach( $title as $dbkey => $id ) { |
| 718 | + $tmpset[] = array( |
| 719 | + 'ft_rev_id' => $rev->getId(), |
| 720 | + 'ft_namespace' => $namespace, |
| 721 | + 'ft_title' => $dbkey, |
| 722 | + 'ft_tmp_rev_id' => $id |
| 723 | + ); |
| 724 | + } |
| 725 | + } |
| 726 | + # Image -> timestamp mapping |
| 727 | + foreach( $poutput->mImageSHA1Keys as $dbkey => $timeAndSHA1 ) { |
| 728 | + foreach( $timeAndSHA1 as $time => $sha1 ) { |
| 729 | + $imgset[] = array( |
| 730 | + 'fi_rev_id' => $rev->getId(), |
| 731 | + 'fi_name' => $dbkey, |
| 732 | + 'fi_img_timestamp' => $time, |
| 733 | + 'fi_img_sha1' => $sha1 |
| 734 | + ); |
| 735 | + } |
| 736 | + } |
| 737 | + |
| 738 | + $dbw = wfGetDB( DB_MASTER ); |
| 739 | + $dbw->begin(); |
| 740 | + # Update our versioning pointers |
| 741 | + if( !empty( $tmpset ) ) { |
| 742 | + $dbw->replace( 'flaggedtemplates', |
| 743 | + array( array('ft_rev_id','ft_namespace','ft_title') ), $tmpset, |
| 744 | + __METHOD__ ); |
| 745 | + } |
| 746 | + if( !empty( $imgset ) ) { |
| 747 | + $dbw->replace( 'flaggedimages', |
| 748 | + array( array('fi_rev_id','fi_name') ), $imgset, |
| 749 | + __METHOD__ ); |
| 750 | + } |
| 751 | + # Get the page text and resolve all templates |
| 752 | + list($fulltext,$complete) = $wgFlaggedRevs->expandText( $rev->getText(), $rev->getTitle(), $rev->getId() ); |
| 753 | + if( !$complete ) { |
| 754 | + $dbw->rollback(); // All versions must be specified, 0 for none |
| 755 | + return false; |
| 756 | + } |
| 757 | + # Compress $fulltext, passed by reference |
| 758 | + $textFlags = self::compressText( $fulltext ); |
| 759 | + # Our review entry |
| 760 | + $revisionset = array( |
| 761 | + 'fr_rev_id' => $rev->getId(), |
| 762 | + 'fr_namespace' => $rev->getTitle()->getNamespace(), |
| 763 | + 'fr_title' => $rev->getTitle()->getDBkey(), |
| 764 | + 'fr_user' => $user->getId(), |
| 765 | + 'fr_timestamp' => wfTimestampNow(), |
| 766 | + 'fr_comment' => '', |
| 767 | + 'fr_quality' => $quality, |
| 768 | + 'fr_text' => $fulltext, // Store expanded text for speed |
| 769 | + 'fr_flags' => $textFlags |
| 770 | + ); |
| 771 | + # Update flagged revisions table |
| 772 | + $dbw->replace( 'flaggedrevs', |
| 773 | + array( array('fr_rev_id','fr_namespace','fr_title') ), $revisionset, |
| 774 | + __METHOD__ ); |
| 775 | + # Set all of our flags |
| 776 | + $dbw->replace( 'flaggedrevtags', |
| 777 | + array( array('frt_rev_id','frt_dimension') ), $flagset, |
| 778 | + __METHOD__ ); |
| 779 | + # Mark as patrolled |
| 780 | + $dbw->update( 'recentchanges', |
| 781 | + array( 'rc_patrolled' => 1 ), |
| 782 | + array( 'rc_this_oldid' => $rev->getId() ), |
| 783 | + __METHOD__ |
| 784 | + ); |
| 785 | + $dbw->commit(); |
| 786 | + |
| 787 | + # Update the article review log |
| 788 | + Revisionreview::updateLog( $rev->getTitle(), $flags, wfMsg('revreview-auto'), |
| 789 | + $rev->getID(), true, false ); |
| 790 | + |
| 791 | + # Might as well save the stable version cache |
| 792 | + $wgFlaggedRevs->updatePageCache( $article, $poutput ); |
| 793 | + # Update page fields |
| 794 | + $wgFlaggedRevs->updateArticleOn( $article, $rev->getID() ); |
| 795 | + # Purge squid for this page only |
| 796 | + $article->mTitle->purgeSquid(); |
| 797 | + |
| 798 | + return true; |
| 799 | + } |
| 800 | + |
689 | 801 | /** |
690 | 802 | * @param Article $article |
691 | 803 | * @param Integer $rev_id, the stable version rev_id |
— | — | @@ -700,7 +812,7 @@ |
701 | 813 | __METHOD__ ); |
702 | 814 | } |
703 | 815 | |
704 | | - public static function updateFromMove( $movePageForm, $oldtitle, $newtitle ) { |
| 816 | + public function updateFromMove( $movePageForm, $oldtitle, $newtitle ) { |
705 | 817 | $dbw = wfGetDB( DB_MASTER ); |
706 | 818 | $dbw->update( 'flaggedrevs', |
707 | 819 | array('fr_namespace' => $newtitle->getNamespace(), 'fr_title' => $newtitle->getDBkey() ), |
— | — | @@ -711,12 +823,12 @@ |
712 | 824 | } |
713 | 825 | |
714 | 826 | /** |
715 | | - * Clears cache for a page when delete is used |
| 827 | + * Clears cache for a page when merges are done. |
| 828 | + * We may have lost the stable revision to another page. |
716 | 829 | */ |
717 | | - public static function articleLinksUpdate( $article, $a=null, $b=null ) { |
| 830 | + public function articleLinksUpdate( $article, $a=null, $b=null ) { |
718 | 831 | global $wgUser, $wgParser; |
719 | | - |
720 | | - // Update the links tables as the stable version may now be the default page... |
| 832 | + # Update the links tables as the stable version may now be the default page... |
721 | 833 | $parserCache =& ParserCache::singleton(); |
722 | 834 | $poutput = $parserCache->get( $article, $wgUser ); |
723 | 835 | if( $poutput==false ) { |
— | — | @@ -734,11 +846,11 @@ |
735 | 847 | /** |
736 | 848 | * Clears cache for a page when revisiondelete/undelete is used |
737 | 849 | */ |
738 | | - public static function articleLinksUpdate2( $title, $a=null, $b=null ) { |
| 850 | + public function articleLinksUpdate2( $title, $a=null, $b=null ) { |
739 | 851 | global $wgUser, $wgParser; |
740 | 852 | |
741 | 853 | $article = new Article( $title ); |
742 | | - // Update the links tables as the stable version may now be the default page... |
| 854 | + # Update the links tables as the stable version may now be the default page... |
743 | 855 | $parserCache =& ParserCache::singleton(); |
744 | 856 | $poutput = $parserCache->get( $article, $wgUser ); |
745 | 857 | if( $poutput==false ) { |
— | — | @@ -756,13 +868,12 @@ |
757 | 869 | /** |
758 | 870 | * Inject stable links on LinksUpdate |
759 | 871 | */ |
760 | | - public static function extraLinksUpdate( $linksUpdate ) { |
| 872 | + public function extraLinksUpdate( $linksUpdate ) { |
761 | 873 | global $wgFlaggedRevs; |
762 | | - |
763 | | - $fname = 'FlaggedRevs::extraLinksUpdate'; |
764 | | - wfProfileIn( $fname ); |
| 874 | + |
| 875 | + wfProfileIn( __METHOD__ ); |
765 | 876 | |
766 | | - if( !FlaggedRevs::isReviewable( $linksUpdate->mTitle ) ) |
| 877 | + if( !$wgFlaggedRevs->isReviewable( $linksUpdate->mTitle ) ) |
767 | 878 | return true; |
768 | 879 | # Check if this page has a stable version |
769 | 880 | $sv = $wgFlaggedRevs->getOverridingRev( $linksUpdate->mTitle, true, true ); |
— | — | @@ -773,9 +884,9 @@ |
774 | 885 | $text = self::uncompressText( $sv->fr_text, $sv->fr_flags ); |
775 | 886 | $parserOut = self::parseStableText( $article, $text, $sv->fr_rev_id ); |
776 | 887 | # Might as well update the stable cache while we're at it |
777 | | - FlaggedRevs::updatePageCache( $article, $parserOut ); |
| 888 | + $wgFlaggedRevs->updatePageCache( $article, $parserOut ); |
778 | 889 | # Update page fields |
779 | | - FlaggedRevs::updateArticleOn( $article, $sv->fr_rev_id ); |
| 890 | + $wgFlaggedRevs->updateArticleOn( $article, $sv->fr_rev_id ); |
780 | 891 | # Update the links tables to include these |
781 | 892 | # We want the UNION of links between the current |
782 | 893 | # and stable version. Therefore, we only care about |
— | — | @@ -800,11 +911,11 @@ |
801 | 912 | * Select the desired templates based on the selected stable revision IDs |
802 | 913 | */ |
803 | 914 | static function parserFetchStableTemplate( $parser, $title, &$skip, &$id ) { |
804 | | - // Trigger for stable version parsing only |
| 915 | + # Trigger for stable version parsing only |
805 | 916 | if( !isset($parser->isStable) || !$parser->isStable ) |
806 | 917 | return true; |
807 | | - // Only called to make fr_text, right after template/image specifiers |
808 | | - // are added to the DB. Slaves may not have it yet... |
| 918 | + # Only called to make fr_text, right after template/image specifiers |
| 919 | + # are added to the DB. Slaves may not have it yet... |
809 | 920 | $dbw = wfGetDB( DB_MASTER ); |
810 | 921 | $id = $dbw->selectField('flaggedtemplates', 'ft_tmp_rev_id', |
811 | 922 | array('ft_rev_id' => $parser->mRevisionId, |
— | — | @@ -824,11 +935,11 @@ |
825 | 936 | * Select the desired images based on the selected stable revision times/SHA-1s |
826 | 937 | */ |
827 | 938 | static function parserMakeStableImageLink( $parser, $nt, &$skip, &$time ) { |
828 | | - // Trigger for stable version parsing only |
| 939 | + # Trigger for stable version parsing only |
829 | 940 | if( !isset($parser->isStable) || !$parser->isStable ) |
830 | 941 | return true; |
831 | | - // Only called to make fr_text, right after template/image specifiers |
832 | | - // are added to the DB. Slaves may not have it yet... |
| 942 | + # Only called to make fr_text, right after template/image specifiers |
| 943 | + # are added to the DB. Slaves may not have it yet... |
833 | 944 | $dbw = wfGetDB( DB_MASTER ); |
834 | 945 | $time = $dbw->selectField('flaggedimages', 'fi_img_timestamp', |
835 | 946 | array('fi_rev_id' => $parser->mRevisionId, 'fi_name' => $nt->getDBkey() ), |
— | — | @@ -847,10 +958,10 @@ |
848 | 959 | * Select the desired images based on the selected stable revision times/SHA-1s |
849 | 960 | */ |
850 | 961 | static function galleryFindStableFileTime( $ig, $nt, &$time ) { |
851 | | - // Trigger for stable version parsing only |
| 962 | + # Trigger for stable version parsing only |
852 | 963 | if( !isset($ig->isStable) || !$ig->isStable ) |
853 | 964 | return true; |
854 | | - // Slaves may not have it yet... |
| 965 | + # Slaves may not have it yet... |
855 | 966 | $dbr = wfGetDB( DB_MASTER ); |
856 | 967 | $time = $dbr->selectField('flaggedimages', 'fi_img_timestamp', |
857 | 968 | array('fi_rev_id' => $ig->mRevisionId, 'fi_name' => $nt->getDBkey() ), |
— | — | @@ -864,7 +975,7 @@ |
865 | 976 | * Flag of an image galley as stable |
866 | 977 | */ |
867 | 978 | static function parserMakeGalleryStable( $parser, $ig ) { |
868 | | - // Trigger for stable version parsing only |
| 979 | + # Trigger for stable version parsing only |
869 | 980 | if( !isset($parser->isStable) || !$parser->isStable ) |
870 | 981 | return true; |
871 | 982 | |
— | — | @@ -906,8 +1017,8 @@ |
907 | 1018 | * Redirect users out to review the changes to the stable version. |
908 | 1019 | * Only for people who can review and for pages that have a stable version. |
909 | 1020 | */ |
910 | | - public static function injectReviewDiffURLParams( $article, &$sectionanchor, &$extraq ) { |
911 | | - global $wgReviewChangesAfterEdit, $wgFlaggedRevs, $wgUser; |
| 1021 | + public function injectReviewDiffURLParams( $article, &$sectionanchor, &$extraq ) { |
| 1022 | + global $wgUser, $wgReviewChangesAfterEdit, $wgFlaggedRevs; |
912 | 1023 | # Was this already autoreviewed? |
913 | 1024 | if( $wgFlaggedRevs->skipReviewDiff ) |
914 | 1025 | return true; |
— | — | @@ -929,7 +1040,7 @@ |
930 | 1041 | * When comparing the stable revision to the current after editing a page, show |
931 | 1042 | * a tag with some explaination for the diff. |
932 | 1043 | */ |
933 | | - public static function addDiffNoticeAfterEdit( $diff, $OldRev, $NewRev ) { |
| 1044 | + public function addDiffNoticeAfterEdit( $diff, $OldRev, $NewRev ) { |
934 | 1045 | global $wgRequest, $wgUser, $wgOut, $wgFlaggedRevs; |
935 | 1046 | |
936 | 1047 | if( !$wgUser->isAllowed( 'review') || !$wgRequest->getBool('editreview') || !$NewRev->isCurrent() ) |
— | — | @@ -956,8 +1067,8 @@ |
957 | 1068 | * When an edit is made by a reviwer, if the current revision is the stable |
958 | 1069 | * version, try to automatically review it. |
959 | 1070 | */ |
960 | | - public static function maybeMakeEditReviewed( $article, $user, $text, $c, $m, $a, $b, $flags, $rev ) { |
961 | | - global $wgFlaggedRevsAutoReview, $wgFlaggedRevs; |
| 1071 | + public function maybeMakeEditReviewed( $article, $user, $text, $c, $m, $a, $b, $flags, $rev ) { |
| 1072 | + global $wgFlaggedRevs, $wgFlaggedRevsAutoReview; |
962 | 1073 | |
963 | 1074 | if( !$wgFlaggedRevsAutoReview || !$user->isAllowed( 'review' ) ) |
964 | 1075 | return true; |
— | — | @@ -994,8 +1105,8 @@ |
995 | 1106 | /** |
996 | 1107 | * When a new page is made by a reviwer, try to automatically review it. |
997 | 1108 | */ |
998 | | - public static function maybeMakeNewPageReviewed( $article, $user, $text, $c, $flags, $a, $b, $flags, $rev ) { |
999 | | - global $wgFlaggedRevsAutoReviewNew, $wgFlaggedRevs; |
| 1109 | + public function maybeMakeNewPageReviewed( $article, $user, $text, $c, $flags, $a, $b, $flags, $rev ) { |
| 1110 | + global $wgFlaggedRevs, $wgFlaggedRevsAutoReviewNew; |
1000 | 1111 | |
1001 | 1112 | if( !$wgFlaggedRevsAutoReviewNew || !$user->isAllowed( 'review' ) ) |
1002 | 1113 | return true; |
— | — | @@ -1015,122 +1126,12 @@ |
1016 | 1127 | |
1017 | 1128 | return true; |
1018 | 1129 | } |
1019 | | - |
1020 | | - /** |
1021 | | - * Automatically review an edit and add a log entry in the review log. |
1022 | | - * LinksUpdate was already called via edit operations, so the page |
1023 | | - * fields will be up to date. This updates the stable version. |
1024 | | - */ |
1025 | | - public static function autoReviewEdit( $article, $user, $text, $rev, $flags ) { |
1026 | | - global $wgParser, $wgFlaggedRevsAutoReview, $wgFlaggedRevs; |
1027 | | - |
1028 | | - $quality = 0; |
1029 | | - if( FlaggedRevs::isQuality($flags) ) { |
1030 | | - $quality = FlaggedRevs::isPristine($flags) ? 2 : 1; |
1031 | | - } |
1032 | | - $flagset = $tmpset = $imgset = array(); |
1033 | | - foreach( $flags as $tag => $value ) { |
1034 | | - $flagset[] = array( |
1035 | | - 'frt_rev_id' => $rev->getId(), |
1036 | | - 'frt_dimension' => $tag, |
1037 | | - 'frt_value' => $value |
1038 | | - ); |
1039 | | - } |
1040 | | - # Try the parser cache, should be set on the edit before this is called. |
1041 | | - # If not set or up to date, then parse it... |
1042 | | - $parserCache =& ParserCache::singleton(); |
1043 | | - $poutput = $parserCache->get( $article, $user ); |
1044 | | - if( $poutput==false ) { |
1045 | | - $options = ParserOptions::newFromUser($user); |
1046 | | - $options->setTidy(true); |
1047 | | - $poutput = $wgParser->parse( $text, $article->mTitle, $options, true, true, $rev->getID() ); |
1048 | | - # Might as well save the cache while we're at it |
1049 | | - $parserCache->save( $poutput, $article, $user ); |
1050 | | - } |
1051 | | - # NS:title -> rev ID mapping |
1052 | | - foreach( $poutput->mTemplateIds as $namespace => $title ) { |
1053 | | - foreach( $title as $dbkey => $id ) { |
1054 | | - $tmpset[] = array( |
1055 | | - 'ft_rev_id' => $rev->getId(), |
1056 | | - 'ft_namespace' => $namespace, |
1057 | | - 'ft_title' => $dbkey, |
1058 | | - 'ft_tmp_rev_id' => $id |
1059 | | - ); |
1060 | | - } |
1061 | | - } |
1062 | | - # Image -> timestamp mapping |
1063 | | - foreach( $poutput->mImageSHA1Keys as $dbkey => $timeAndSHA1 ) { |
1064 | | - foreach( $timeAndSHA1 as $time => $sha1 ) { |
1065 | | - $imgset[] = array( |
1066 | | - 'fi_rev_id' => $rev->getId(), |
1067 | | - 'fi_name' => $dbkey, |
1068 | | - 'fi_img_timestamp' => $time, |
1069 | | - 'fi_img_sha1' => $sha1 |
1070 | | - ); |
1071 | | - } |
1072 | | - } |
1073 | | - |
1074 | | - $dbw = wfGetDB( DB_MASTER ); |
1075 | | - $dbw->begin(); |
1076 | | - # Update our versioning pointers |
1077 | | - if( !empty( $tmpset ) ) { |
1078 | | - $dbw->replace( 'flaggedtemplates', array( array('ft_rev_id','ft_namespace','ft_title') ), $tmpset, |
1079 | | - __METHOD__ ); |
1080 | | - } |
1081 | | - if( !empty( $imgset ) ) { |
1082 | | - $dbw->replace( 'flaggedimages', array( array('fi_rev_id','fi_name') ), $imgset, |
1083 | | - __METHOD__ ); |
1084 | | - } |
1085 | | - # Get the page text and resolve all templates |
1086 | | - list($fulltext,$complete) = FlaggedRevs::expandText( $rev->getText(), $rev->getTitle(), $rev->getId() ); |
1087 | | - if( !$complete ) { |
1088 | | - $dbw->rollback(); // All versions must be specified, 0 for none |
1089 | | - return false; |
1090 | | - } |
1091 | | - # Compress $fulltext, passed by reference |
1092 | | - $textFlags = self::compressText( $fulltext ); |
1093 | | - # Our review entry |
1094 | | - $revset = array( |
1095 | | - 'fr_rev_id' => $rev->getId(), |
1096 | | - 'fr_namespace' => $rev->getTitle()->getNamespace(), |
1097 | | - 'fr_title' => $rev->getTitle()->getDBkey(), |
1098 | | - 'fr_user' => $user->getId(), |
1099 | | - 'fr_timestamp' => wfTimestampNow(), |
1100 | | - 'fr_comment' => '', |
1101 | | - 'fr_quality' => $quality, |
1102 | | - 'fr_text' => $fulltext, // Store expanded text for speed |
1103 | | - 'fr_flags' => $textFlags |
1104 | | - ); |
1105 | | - # Update flagged revisions table |
1106 | | - $dbw->replace( 'flaggedrevs', array( array('fr_rev_id','fr_namespace','fr_title') ), $revset, __METHOD__ ); |
1107 | | - # Set all of our flags |
1108 | | - $dbw->replace( 'flaggedrevtags', array( array('frt_rev_id','frt_dimension') ), $flagset, __METHOD__ ); |
1109 | | - # Mark as patrolled |
1110 | | - $dbw->update( 'recentchanges', |
1111 | | - array( 'rc_patrolled' => 1 ), |
1112 | | - array( 'rc_this_oldid' => $rev->getId() ), |
1113 | | - __METHOD__ |
1114 | | - ); |
1115 | | - $dbw->commit(); |
1116 | | - |
1117 | | - # Update the article review log |
1118 | | - Revisionreview::updateLog( $rev->getTitle(), $flags, wfMsg('revreview-auto'), $rev->getID(), true, false ); |
1119 | | - |
1120 | | - # Might as well save the stable cache |
1121 | | - $wgFlaggedRevs->updatePageCache( $article, $poutput ); |
1122 | | - # Update page fields |
1123 | | - FlaggedRevs::updateArticleOn( $article, $rev->getID() ); |
1124 | | - # Purge squid for this page only |
1125 | | - $article->mTitle->purgeSquid(); |
1126 | | - |
1127 | | - return true; |
1128 | | - } |
1129 | 1130 | |
1130 | 1131 | /** |
1131 | 1132 | * Callback that autopromotes user according to the setting in |
1132 | 1133 | * $wgFlaggedRevsAutopromote. This is not as efficient as it should be |
1133 | 1134 | */ |
1134 | | - public static function autoPromoteUser( $article, $user, &$text, &$summary, &$isminor, &$iswatch, &$section ) { |
| 1135 | + public function autoPromoteUser( $article, $user, &$text, &$summary, &$isminor, &$iswatch, &$section ) { |
1135 | 1136 | global $wgUser, $wgFlaggedRevsAutopromote; |
1136 | 1137 | |
1137 | 1138 | if( !$wgFlaggedRevsAutopromote ) |
— | — | @@ -1208,32 +1209,30 @@ |
1209 | 1210 | /** |
1210 | 1211 | * Updates parser cache output to included needed versioning params. |
1211 | 1212 | */ |
1212 | | - public static function maybeUpdateMainCache( $article, &$outputDone, &$pcache ) { |
1213 | | - global $wgUser, $action; |
1214 | | - // Only trigger on article view for content pages, not for protect/delete/hist |
| 1213 | + public function maybeUpdateMainCache( $article, &$outputDone, &$pcache ) { |
| 1214 | + global $wgUser, $action, $wgFlaggedRevs; |
| 1215 | + # Only trigger on article view for content pages, not for protect/delete/hist |
1215 | 1216 | if( $action !='view' || !$wgUser->isAllowed( 'review' ) ) |
1216 | 1217 | return true; |
1217 | | - if( !$article || !$article->exists() || !FlaggedRevs::isReviewable( $article->mTitle ) ) |
| 1218 | + if( !$article || !$article->exists() || !$wgFlaggedRevs->isReviewable( $article->mTitle ) ) |
1218 | 1219 | return true; |
1219 | 1220 | |
1220 | 1221 | $parserCache =& ParserCache::singleton(); |
1221 | 1222 | $parserOut = $parserCache->get( $article, $wgUser ); |
1222 | 1223 | if( $parserOut ) { |
1223 | | - // Clear older, incomplete, cached versions |
1224 | | - // We need the IDs of templates and timestamps of images used |
| 1224 | + # Clear older, incomplete, cached versions |
| 1225 | + # We need the IDs of templates and timestamps of images used |
1225 | 1226 | if( !isset($parserOut->mTemplateIds) || !isset($parserOut->mImageSHA1Keys) ) |
1226 | 1227 | $article->mTitle->invalidateCache(); |
1227 | 1228 | } |
1228 | 1229 | return true; |
1229 | 1230 | } |
1230 | 1231 | |
1231 | | - ######### |
1232 | | - |
1233 | 1232 | ######### Stub functions, overridden by subclass ######### |
1234 | 1233 | |
1235 | 1234 | static function pageOverride() { return false; } |
1236 | 1235 | |
1237 | | - function setPageContent( $article, $outputDone, &$pcache ) {} |
| 1236 | + function setPageContent( $article, &$outputDone, &$pcache ) {} |
1238 | 1237 | |
1239 | 1238 | function addToEditView( $editform ) {} |
1240 | 1239 | |
— | — | @@ -1263,9 +1262,10 @@ |
1264 | 1263 | * for overriding by stable revisions? |
1265 | 1264 | */ |
1266 | 1265 | static function pageOverride() { |
1267 | | - global $wgTitle, $wgFlaggedRevsAnonOnly, $wgFlaggedRevsOverride, $wgUser, $wgRequest, $action; |
| 1266 | + global $wgFlaggedRevsAnonOnly, $wgFlaggedRevsOverride, $wgFlaggedRevs, |
| 1267 | + $wgTitle, $wgUser, $wgRequest, $action; |
1268 | 1268 | # This only applies to viewing content pages |
1269 | | - if( $action !='view' || !FlaggedRevs::isReviewable( $wgTitle ) ) |
| 1269 | + if( $action !='view' || !$wgFlaggedRevs->isReviewable( $wgTitle ) ) |
1270 | 1270 | return; |
1271 | 1271 | # Does not apply to diffs/old revisions |
1272 | 1272 | if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') ) |
— | — | @@ -1289,9 +1289,9 @@ |
1290 | 1290 | * Adds a quick review form on the bottom if needed |
1291 | 1291 | */ |
1292 | 1292 | function setPageContent( $article, &$outputDone, &$pcache ) { |
1293 | | - global $wgRequest, $wgTitle, $wgOut, $action, $wgUser; |
| 1293 | + global $wgRequest, $wgTitle, $wgOut, $action, $wgUser, $wgFlaggedRevs; |
1294 | 1294 | // Only trigger on article view for content pages, not for protect/delete/hist |
1295 | | - if( $action !='view' || !$article || !$article->exists() || !FlaggedRevs::isReviewable( $article->mTitle ) ) |
| 1295 | + if( $action !='view' || !$article || !$article->exists() || !$wgFlaggedRevs->isReviewable( $article->mTitle ) ) |
1296 | 1296 | return true; |
1297 | 1297 | // Grab page and rev ids |
1298 | 1298 | $pageid = $article->getId(); |
— | — | @@ -1303,7 +1303,7 @@ |
1304 | 1304 | |
1305 | 1305 | $vis_id = $revid; |
1306 | 1306 | $tag = ''; $notes = ''; |
1307 | | - // Check the newest stable version... |
| 1307 | + # Check the newest stable version... |
1308 | 1308 | $tfrev = $this->getOverridingRev(); |
1309 | 1309 | $simpleTag = false; |
1310 | 1310 | if( $wgRequest->getVal('diff') || $wgRequest->getVal('oldid') ) { |
— | — | @@ -1313,19 +1313,19 @@ |
1314 | 1314 | # Get flags and date |
1315 | 1315 | $flags = $this->getFlagsForRevision( $tfrev->fr_rev_id ); |
1316 | 1316 | # Get quality level |
1317 | | - $quality = parent::isQuality( $flags ); |
1318 | | - $pristine = parent::isPristine( $flags ); |
| 1317 | + $quality = $this->isQuality( $flags ); |
| 1318 | + $pristine = $this->isPristine( $flags ); |
1319 | 1319 | $time = $wgLang->date( wfTimestamp(TS_MW, $tfrev->fr_timestamp), true ); |
1320 | 1320 | # Looking at some specific old rev or if flagged revs override only for anons |
1321 | 1321 | if( !$this->pageOverride() ) { |
1322 | | - $revs_since = parent::getRevCountSince( $pageid, $tfrev->fr_rev_id ); |
| 1322 | + $revs_since = $this->getRevCountSince( $pageid, $tfrev->fr_rev_id ); |
1323 | 1323 | $simpleTag = true; |
1324 | 1324 | # Construct some tagging |
1325 | 1325 | if( !$wgOut->isPrintable() ) { |
1326 | 1326 | if( $this->useSimpleUI() ) { |
1327 | 1327 | $msg = $quality ? 'revreview-quick-see-quality' : 'revreview-quick-see-basic'; |
1328 | 1328 | $tag .= "<span class='fr_tab_current plainlinks'></span>" . wfMsgExt($msg,array('parseinline')); |
1329 | | - $tag .= parent::prettyRatingBox( $tfrev, $flags, $revs_since, false ); |
| 1329 | + $tag .= $this->prettyRatingBox( $tfrev, $flags, $revs_since, false ); |
1330 | 1330 | } else { |
1331 | 1331 | $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic'; |
1332 | 1332 | $tag .= wfMsgExt($msg, array('parseinline'), $tfrev->fr_rev_id, $time, $revs_since); |
— | — | @@ -1333,39 +1333,39 @@ |
1334 | 1334 | $tag .= ' <a id="mw-revisiontoggle" style="display:none;" href="javascript:toggleRevRatings()">' . |
1335 | 1335 | wfMsg('revreview-toggle') . '</a>'; |
1336 | 1336 | $tag .= '<span id="mw-revisionratings" style="display:block;">' . |
1337 | | - wfMsg('revreview-oldrating') . parent::addTagRatings( $flags ) . '</span>'; |
| 1337 | + wfMsg('revreview-oldrating') . $this->addTagRatings( $flags ) . '</span>'; |
1338 | 1338 | } |
1339 | 1339 | } |
1340 | | - # Viewing the page normally: override the page |
| 1340 | + // Viewing the page normally: override the page |
1341 | 1341 | } else { |
1342 | 1342 | # We will be looking at the reviewed revision... |
1343 | 1343 | $vis_id = $tfrev->fr_rev_id; |
1344 | | - $revs_since = parent::getRevCountSince( $pageid, $vis_id ); |
1345 | | - // Construct some tagging |
| 1344 | + $revs_since = $this->getRevCountSince( $pageid, $vis_id ); |
| 1345 | + # Construct some tagging |
1346 | 1346 | if( !$wgOut->isPrintable() ) { |
1347 | 1347 | if( $this->useSimpleUI() ) { |
1348 | 1348 | $msg = $quality ? 'revreview-quick-quality' : 'revreview-quick-basic'; |
1349 | 1349 | $css = $quality ? 'fr_tab_quality' : 'fr_tab_stable'; |
1350 | 1350 | $tag .= "<span class='$css plainlinks'></span>" . |
1351 | 1351 | wfMsgExt($msg,array('parseinline'),$tfrev->fr_rev_id,$revs_since); |
1352 | | - $tag .= parent::prettyRatingBox( $tfrev, $flags, $revs_since ); |
| 1352 | + $tag .= $this->prettyRatingBox( $tfrev, $flags, $revs_since ); |
1353 | 1353 | } else { |
1354 | 1354 | $msg = $quality ? 'revreview-quality' : 'revreview-basic'; |
1355 | 1355 | $tag = wfMsgExt($msg, array('parseinline'), $vis_id, $time, $revs_since); |
1356 | 1356 | $tag .= ' <a id="mw-revisiontoggle" style="display:none;" href="javascript:toggleRevRatings()">' . |
1357 | 1357 | wfMsg('revreview-toggle') . '</a>'; |
1358 | 1358 | $tag .= '<span id="mw-revisionratings" style="display:block;">' . |
1359 | | - parent::addTagRatings( $flags ) . '</span>'; |
| 1359 | + $this->addTagRatings( $flags ) . '</span>'; |
1360 | 1360 | } |
1361 | 1361 | } |
1362 | 1362 | # Try the stable page cache |
1363 | | - $parserOut = parent::getPageCache( $article ); |
| 1363 | + $parserOut = $this->getPageCache( $article ); |
1364 | 1364 | # If no cache is available, get the text and parse it |
1365 | 1365 | if( $parserOut==false ) { |
1366 | | - $text = parent::getFlaggedRevText( $vis_id ); |
1367 | | - $parserOut = parent::parseStableText( $article, $text, $vis_id ); |
| 1366 | + $text = $this->getFlaggedRevText( $vis_id ); |
| 1367 | + $parserOut = $this->parseStableText( $article, $text, $vis_id ); |
1368 | 1368 | # Update the general cache |
1369 | | - parent::updatePageCache( $article, $parserOut ); |
| 1369 | + $this->updatePageCache( $article, $parserOut ); |
1370 | 1370 | } |
1371 | 1371 | $wgOut->mBodytext = $parserOut->getText(); |
1372 | 1372 | # Show stable categories and interwiki links only |
— | — | @@ -1373,12 +1373,12 @@ |
1374 | 1374 | $wgOut->addCategoryLinks( $parserOut->getCategories() ); |
1375 | 1375 | $wgOut->mLanguageLinks = array(); |
1376 | 1376 | $wgOut->addLanguageLinks( $parserOut->getLanguageLinks() ); |
1377 | | - $notes = parent::ReviewNotes( $tfrev ); |
| 1377 | + $notes = $this->ReviewNotes( $tfrev ); |
1378 | 1378 | # Tell MW that parser output is done |
1379 | 1379 | $outputDone = true; |
1380 | 1380 | $pcache = false; |
1381 | 1381 | } |
1382 | | - // Some checks for which tag CSS to use |
| 1382 | + # Some checks for which tag CSS to use |
1383 | 1383 | if( $this->useSimpleUI() ) |
1384 | 1384 | $tagClass = 'flaggedrevs_short'; |
1385 | 1385 | else if( $simpleTag ) |
— | — | @@ -1389,13 +1389,13 @@ |
1390 | 1390 | $tagClass = 'flaggedrevs_tag2'; |
1391 | 1391 | else |
1392 | 1392 | $tagClass = 'flaggedrevs_tag1'; |
1393 | | - // Wrap tag contents in a div |
| 1393 | + # Wrap tag contents in a div |
1394 | 1394 | if( $tag !='' ) |
1395 | 1395 | $tag = '<div id="mw-revisiontag" class="' . $tagClass . ' plainlinks">'.$tag.'</div>'; |
1396 | | - // Set the new body HTML, place a tag on top |
| 1396 | + # Set the new body HTML, place a tag on top |
1397 | 1397 | $wgOut->mBodytext = $tag . $wgOut->mBodytext . $notes; |
1398 | 1398 | // Add "no reviewed version" tag, but not for main page |
1399 | | - } else if( !$wgOut->isPrintable() && !parent::isMainPage( $article->mTitle ) ) { |
| 1399 | + } else if( !$wgOut->isPrintable() && !$this->isMainPage( $article->mTitle ) ) { |
1400 | 1400 | if( $this->useSimpleUI() ) { |
1401 | 1401 | $tag .= "<span class='fr_tab_current plainlinks'></span>" . |
1402 | 1402 | wfMsgExt('revreview-quick-none',array('parseinline')); |
— | — | @@ -1410,40 +1410,40 @@ |
1411 | 1411 | } |
1412 | 1412 | |
1413 | 1413 | function addToEditView( $editform ) { |
1414 | | - global $wgRequest, $wgTitle, $wgOut; |
1415 | | - // Talk pages cannot be validated |
1416 | | - if( !$editform->mArticle || !FlaggedRevs::isReviewable( $wgTitle ) ) |
| 1414 | + global $wgRequest, $wgTitle, $wgOut, $wgFlaggedRevs; |
| 1415 | + # Talk pages cannot be validated |
| 1416 | + if( !$editform->mArticle || !$wgFlaggedRevs->isReviewable( $wgTitle ) ) |
1417 | 1417 | return false; |
1418 | | - // Find out revision id |
| 1418 | + # Find out revision id |
1419 | 1419 | if( $editform->mArticle->mRevision ) { |
1420 | 1420 | $revid = $editform->mArticle->mRevision->mId; |
1421 | 1421 | } else { |
1422 | 1422 | $revid = $editform->mArticle->getLatest(); |
1423 | 1423 | } |
1424 | | - // Grab the ratings for this revision if any |
| 1424 | + # Grab the ratings for this revision if any |
1425 | 1425 | if( !$revid ) |
1426 | 1426 | return true; |
1427 | | - // Set new body html text as that of now |
| 1427 | + # Set new body html text as that of now |
1428 | 1428 | $tag = ''; |
1429 | | - // Check the newest stable version |
| 1429 | + # Check the newest stable version |
1430 | 1430 | $tfrev = $this->getOverridingRev(); |
1431 | 1431 | if( is_object($tfrev) ) { |
1432 | 1432 | global $wgLang, $wgUser, $wgFlaggedRevs, $wgFlaggedRevsAutoReview; |
1433 | 1433 | |
1434 | 1434 | $time = $wgLang->date( wfTimestamp(TS_MW, $tfrev->fr_timestamp), true ); |
1435 | 1435 | $flags = $this->getFlagsForRevision( $tfrev->fr_rev_id ); |
1436 | | - $revs_since = parent::getRevCountSince( $editform->mArticle->getID(), $tfrev->fr_rev_id ); |
| 1436 | + $revs_since = $this->getRevCountSince( $editform->mArticle->getID(), $tfrev->fr_rev_id ); |
1437 | 1437 | # Construct some tagging |
1438 | | - $msg = parent::isQuality( $flags ) ? 'revreview-newest-quality' : 'revreview-newest-basic'; |
| 1438 | + $msg = $this->isQuality( $flags ) ? 'revreview-newest-quality' : 'revreview-newest-basic'; |
1439 | 1439 | $tag = wfMsgExt($msg, array('parseinline'), $tfrev->fr_rev_id, $time, $revs_since ); |
1440 | 1440 | # Hide clutter |
1441 | 1441 | $tag .= ' <a id="mw-revisiontoggle" style="display:none;" href="javascript:toggleRevRatings()">' . |
1442 | 1442 | wfMsg('revreview-toggle') . '</a>'; |
1443 | 1443 | $tag .= '<span id="mw-revisionratings" style="display:block;">' . |
1444 | | - wfMsg('revreview-oldrating') . parent::addTagRatings( $flags ) . |
| 1444 | + wfMsg('revreview-oldrating') . $this->addTagRatings( $flags ) . |
1445 | 1445 | '</span>'; |
1446 | 1446 | $wgOut->addHTML( '<div id="mw-revisiontag" class="flaggedrevs_notice plainlinks">' . $tag . '</div>' ); |
1447 | | - // If this will be autoreviewed, notify the user... |
| 1447 | + # If this will be autoreviewed, notify the user... |
1448 | 1448 | if( !$wgFlaggedRevsAutoReview ) |
1449 | 1449 | return true; |
1450 | 1450 | if( $wgUser->isAllowed('review') && $revid==$tfrev->fr_rev_id && $revid==$editform->mArticle->getLatest() ) { |
— | — | @@ -1464,22 +1464,22 @@ |
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | function addReviewForm( $out ) { |
1468 | | - global $wgArticle, $wgRequest, $action; |
| 1468 | + global $wgArticle, $wgRequest, $action, $wgFlaggedRevs; |
1469 | 1469 | |
1470 | | - if( !$wgArticle || !$wgArticle->exists() || !FlaggedRevs::isReviewable( $wgArticle->mTitle ) ) |
| 1470 | + if( !$wgArticle || !$wgArticle->exists() || !$wgFlaggedRevs->isReviewable( $wgArticle->mTitle ) ) |
1471 | 1471 | return true; |
1472 | | - // Check if page is protected |
| 1472 | + # Check if page is protected |
1473 | 1473 | if( $action !='view' || !$wgArticle->mTitle->quickUserCan( 'edit' ) ) { |
1474 | 1474 | return true; |
1475 | 1475 | } |
1476 | | - // Get revision ID |
| 1476 | + # Get revision ID |
1477 | 1477 | $revId = $out->mRevisionId ? $out->mRevisionId : $wgArticle->getLatest(); |
1478 | | - // We cannot review deleted revisions |
| 1478 | + # We cannot review deleted revisions |
1479 | 1479 | if( is_object($wgArticle->mRevision) && $wgArticle->mRevision->mDeleted ) |
1480 | 1480 | return true; |
1481 | | - // Add quick review links IF we did not override, otherwise, they might |
1482 | | - // review a revision that parses out newer templates/images than what they saw. |
1483 | | - // Revisions are always reviewed based on current templates/images. |
| 1481 | + # Add quick review links IF we did not override, otherwise, they might |
| 1482 | + # review a revision that parses out newer templates/images than what they saw. |
| 1483 | + # Revisions are always reviewed based on current templates/images. |
1484 | 1484 | if( $this->pageOverride() ) { |
1485 | 1485 | $tfrev = $this->getOverridingRev(); |
1486 | 1486 | if( $tfrev ) |
— | — | @@ -1491,23 +1491,24 @@ |
1492 | 1492 | } |
1493 | 1493 | |
1494 | 1494 | function setPermaLink( $sktmp, &$nav_urls, &$revid, &$revid ) { |
1495 | | - // Non-content pages cannot be validated |
| 1495 | + global $wgFlaggedRevs; |
| 1496 | + # Non-content pages cannot be validated |
1496 | 1497 | if( !$this->pageOverride() ) |
1497 | 1498 | return true; |
1498 | | - // Check for an overridabe revision |
| 1499 | + # Check for an overridabe revision |
1499 | 1500 | $tfrev = $this->getOverridingRev(); |
1500 | 1501 | if( !$tfrev ) |
1501 | 1502 | return true; |
1502 | | - // Replace "permalink" with an actual permanent link |
| 1503 | + # Replace "permalink" with an actual permanent link |
1503 | 1504 | $nav_urls['permalink'] = array( |
1504 | 1505 | 'text' => wfMsg( 'permalink' ), |
1505 | 1506 | 'href' => $sktmp->makeSpecialUrl( 'Stableversions', "oldid={$tfrev->fr_rev_id}" ) |
1506 | 1507 | ); |
1507 | 1508 | |
1508 | 1509 | global $wgHooks; |
1509 | | - // Are we using the popular cite extension? |
| 1510 | + # Are we using the popular cite extension? |
1510 | 1511 | if( in_array('wfSpecialCiteNav',$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink']) ) { |
1511 | | - if( FlaggedRevs::isReviewable( $sktmp->mTitle ) && $revid !== 0 ) { |
| 1512 | + if( $wgFlaggedRevs->isReviewable( $sktmp->mTitle ) && $revid !== 0 ) { |
1512 | 1513 | $nav_urls['cite'] = array( |
1513 | 1514 | 'text' => wfMsg( 'cite_article_link' ), |
1514 | 1515 | 'href' => $sktmp->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$sktmp->thispage}" ) . "&id={$tfrev->fr_rev_id}" ) |
— | — | @@ -1518,20 +1519,20 @@ |
1519 | 1520 | } |
1520 | 1521 | |
1521 | 1522 | function setCurrentTab( $sktmp, &$content_actions ) { |
1522 | | - global $wgRequest, $wgUser, $action, $wgFlaggedRevsAnonOnly, |
| 1523 | + global $wgRequest, $wgUser, $action, $wgFlaggedRevs, $wgFlaggedRevsAnonOnly, |
1523 | 1524 | $wgFlaggedRevsOverride, $wgFlaggedRevTabs; |
1524 | | - // Get the subject page, not all skins have it :( |
| 1525 | + # Get the subject page, not all skins have it :( |
1525 | 1526 | if( !isset($sktmp->mTitle) ) |
1526 | 1527 | return true; |
1527 | 1528 | $title = $sktmp->mTitle->getSubjectPage(); |
1528 | | - // Non-content pages cannot be validated |
1529 | | - if( !FlaggedRevs::isReviewable( $title ) || !$title->exists() ) |
| 1529 | + # Non-content pages cannot be validated |
| 1530 | + if( !$wgFlaggedRevs->isReviewable( $title ) || !$title->exists() ) |
1530 | 1531 | return true; |
1531 | 1532 | $article = new Article( $title ); |
1532 | | - // If we are viewing a page normally, and it was overridden, |
1533 | | - // change the edit tab to a "current revision" tab |
| 1533 | + # If we are viewing a page normally, and it was overridden, |
| 1534 | + # change the edit tab to a "current revision" tab |
1534 | 1535 | $tfrev = $this->getOverridingRev(); |
1535 | | - // No quality revs? Find the last reviewed one |
| 1536 | + # No quality revs? Find the last reviewed one |
1536 | 1537 | if( !is_object($tfrev) ) |
1537 | 1538 | return true; |
1538 | 1539 | /* |
— | — | @@ -1540,7 +1541,7 @@ |
1541 | 1542 | return true; |
1542 | 1543 | } |
1543 | 1544 | */ |
1544 | | - // Be clear about what is being edited... |
| 1545 | + # Be clear about what is being edited... |
1545 | 1546 | if( !$sktmp->mTitle->isTalkPage() && !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) ) { |
1546 | 1547 | if( isset( $content_actions['edit'] ) ) |
1547 | 1548 | $content_actions['edit']['text'] = wfMsg('revreview-edit'); |
— | — | @@ -1551,7 +1552,7 @@ |
1552 | 1553 | if( !$wgFlaggedRevTabs ) { |
1553 | 1554 | return true; |
1554 | 1555 | } |
1555 | | - // Note that revisions may not be set to override for users |
| 1556 | + // We are looking at the stable version |
1556 | 1557 | if( $this->pageOverride() ) { |
1557 | 1558 | $new_actions = array(); $counter = 0; |
1558 | 1559 | # Straighten out order |
— | — | @@ -1646,8 +1647,7 @@ |
1647 | 1648 | $rows = $this->getReviewedRevs( $article->getTitle() ); |
1648 | 1649 | if( !$rows ) |
1649 | 1650 | return true; |
1650 | | - // Try to keep the skin readily accesible, |
1651 | | - // addToHistLine() will use it |
| 1651 | + # Try to keep the skin readily accesible; addToHistLine() will use it |
1652 | 1652 | $this->skin = $wgUser->getSkin(); |
1653 | 1653 | |
1654 | 1654 | foreach( $rows as $rev => $quality ) |
— | — | @@ -1673,21 +1673,21 @@ |
1674 | 1674 | function addQuickReview( $id=NULL, $out, $top=false ) { |
1675 | 1675 | global $wgOut, $wgTitle, $wgUser, $wgRequest, |
1676 | 1676 | $wgFlaggedRevsOverride, $wgFlaggedRevComments, $wgFlaggedRevsWatch; |
1677 | | - // User must have review rights |
| 1677 | + # User must have review rights |
1678 | 1678 | if( !$wgUser->isAllowed( 'review' ) ) |
1679 | 1679 | return; |
1680 | | - // Looks ugly when printed |
| 1680 | + # Looks ugly when printed |
1681 | 1681 | if( $out->isPrintable() ) |
1682 | 1682 | return; |
1683 | 1683 | |
1684 | 1684 | $skin = $wgUser->getSkin(); |
1685 | | - // If we are reviewing updates to a page, start off with the stable revision's |
1686 | | - // flags. Otherwise, we just fill them in with the selected revision's flags. |
| 1685 | + # If we are reviewing updates to a page, start off with the stable revision's |
| 1686 | + # flags. Otherwise, we just fill them in with the selected revision's flags. |
1687 | 1687 | if( $this->isDiffFromStable ) { |
1688 | 1688 | $flags = $this->getFlagsForRevision( $wgRequest->getVal('oldid') ); |
1689 | | - // Check if user is allowed to renew the stable version. |
1690 | | - // It may perhaps have been reviewed too highly for this user, if so, |
1691 | | - // then get the flags for the new revision itself. |
| 1689 | + # Check if user is allowed to renew the stable version. |
| 1690 | + # It may perhaps have been reviewed too highly for this user, if so, |
| 1691 | + # then get the flags for the new revision itself. |
1692 | 1692 | foreach( $flags as $quality => $level ) { |
1693 | 1693 | if( !Revisionreview::userCan($quality,$level) ) { |
1694 | 1694 | $flags = $this->getFlagsForRevision( $id ); |
— | — | @@ -1716,7 +1716,7 @@ |
1717 | 1717 | $options = ''; $disabled = ''; |
1718 | 1718 | foreach( $levels as $idx => $label ) { |
1719 | 1719 | $selected = ( $flags[$quality]==$idx || $flags[$quality]==0 && $idx==1 ) ? "selected='selected'" : ''; |
1720 | | - // Do not show options user's can't set unless that is the status quo |
| 1720 | + # Do not show options user's can't set unless that is the status quo |
1721 | 1721 | if( !Revisionreview::userCan($quality, $flags[$quality]) ) { |
1722 | 1722 | $disabled = 'disabled = true'; |
1723 | 1723 | $options .= "<option value='$idx' $selected>" . wfMsgHtml("revreview-$label") . "</option>\n"; |
— | — | @@ -1738,7 +1738,7 @@ |
1739 | 1739 | if( !isset($out->mTemplateIds) || !isset($out->mImageSHA1Keys) ) { |
1740 | 1740 | return; // something went terribly wrong... |
1741 | 1741 | } |
1742 | | - // Hack, add NS:title -> rev ID mapping |
| 1742 | + # Hack, add NS:title -> rev ID mapping |
1743 | 1743 | foreach( $out->mTemplateIds as $namespace => $title ) { |
1744 | 1744 | foreach( $title as $dbkey => $id ) { |
1745 | 1745 | $title = Title::makeTitle( $namespace, $dbkey ); |
— | — | @@ -1746,7 +1746,7 @@ |
1747 | 1747 | } |
1748 | 1748 | } |
1749 | 1749 | $form .= Xml::hidden( 'templateParams', $templateParams ) . "\n"; |
1750 | | - // Hack, image -> timestamp mapping |
| 1750 | + # Hack, image -> timestamp mapping |
1751 | 1751 | foreach( $out->mImageSHA1Keys as $dbkey => $timeAndSHA1 ) { |
1752 | 1752 | foreach( $timeAndSHA1 as $time => $sha1 ) { |
1753 | 1753 | $imageParams .= $dbkey . "|" . $time . "|" . $sha1 . "#"; |
— | — | @@ -1757,7 +1757,7 @@ |
1758 | 1758 | $watchLabel = wfMsgExt('watchthis', array('parseinline')); |
1759 | 1759 | $watchAttribs = array('accesskey' => wfMsg( 'accesskey-watch' ), 'id' => 'wpWatchthis'); |
1760 | 1760 | $watchChecked = ( $wgFlaggedRevsWatch && $wgUser->getOption( 'watchdefault' ) || $wgTitle->userIsWatching() ); |
1761 | | - // Not much to say unless you are a validator |
| 1761 | + # Not much to say unless you are a validator |
1762 | 1762 | if( $wgUser->isAllowed( 'validate' ) ) |
1763 | 1763 | $form .= "<p>".wfInputLabel( wfMsgHtml( 'revreview-log' ), 'wpReason', 'wpReason', 60 )."</p>\n"; |
1764 | 1764 | |
— | — | @@ -1781,7 +1781,7 @@ |
1782 | 1782 | */ |
1783 | 1783 | function getOverridingRev( $title = NULL, $getText=false, $forUpdate=false ) { |
1784 | 1784 | global $wgTitle; |
1785 | | - // Get the content page, skip talk |
| 1785 | + # Get the content page, skip talk |
1786 | 1786 | $title = $wgTitle->getSubjectPage(); |
1787 | 1787 | |
1788 | 1788 | if( !$forUpdate ) { |
— | — | @@ -1795,7 +1795,7 @@ |
1796 | 1796 | $this->stablerev = $row; |
1797 | 1797 | return $row; |
1798 | 1798 | } |
1799 | | - // Cached results available? |
| 1799 | + # Cached results available? |
1800 | 1800 | if( isset($this->stablefound) ) { |
1801 | 1801 | return ( $this->stablefound ) ? $this->stablerev : null; |
1802 | 1802 | } |
— | — | @@ -1807,7 +1807,6 @@ |
1808 | 1808 | } |
1809 | 1809 | |
1810 | 1810 | $dbw = wfGetDB( DB_MASTER ); |
1811 | | - // Skip deleted revisions |
1812 | 1811 | $result = $dbw->select( array('page', 'flaggedrevs', 'revision'), |
1813 | 1812 | $selectColumns, |
1814 | 1813 | array('page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), |
— | — | @@ -1815,8 +1814,7 @@ |
1816 | 1815 | 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
1817 | 1816 | __METHOD__, |
1818 | 1817 | array('LIMIT' => 1) ); |
1819 | | - |
1820 | | - // Do we have one? |
| 1818 | + # Do we have one? |
1821 | 1819 | if( $row = $dbw->fetchObject($result) ) { |
1822 | 1820 | $this->stablefound = true; |
1823 | 1821 | $this->stablerev = $row; |
— | — | @@ -1838,9 +1836,9 @@ |
1839 | 1837 | */ |
1840 | 1838 | function getLatestQualityRev( $getText=false ) { |
1841 | 1839 | global $wgTitle; |
1842 | | - // Get the content page, skip talk |
| 1840 | + # Get the content page, skip talk |
1843 | 1841 | $title = $wgTitle->getSubjectPage(); |
1844 | | - // Cached results available? |
| 1842 | + # Cached results available? |
1845 | 1843 | if( isset($this->qualityfound) ) { |
1846 | 1844 | return ( $this->qualityfound ) ? $this->qualityrev : null; |
1847 | 1845 | } |
— | — | @@ -1852,7 +1850,6 @@ |
1853 | 1851 | } |
1854 | 1852 | |
1855 | 1853 | $dbr = wfGetDB( DB_SLAVE ); |
1856 | | - // Skip deleted revisions |
1857 | 1854 | $result = $dbr->select( array('flaggedrevs', 'revision'), |
1858 | 1855 | $selectColumns, |
1859 | 1856 | array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), 'fr_quality >= 1', |
— | — | @@ -1880,9 +1877,9 @@ |
1881 | 1878 | */ |
1882 | 1879 | function getLatestStableRev( $getText=false ) { |
1883 | 1880 | global $wgTitle; |
1884 | | - // Get the content page, skip talk |
| 1881 | + # Get the content page, skip talk |
1885 | 1882 | $title = $wgTitle->getSubjectPage(); |
1886 | | - // Cached results available? |
| 1883 | + # Cached results available? |
1887 | 1884 | if( isset($this->latestfound) ) { |
1888 | 1885 | return ( $this->latestfound ) ? $this->latestrev : NULL; |
1889 | 1886 | } |
— | — | @@ -1894,15 +1891,14 @@ |
1895 | 1892 | } |
1896 | 1893 | |
1897 | 1894 | $dbr = wfGetDB( DB_SLAVE ); |
1898 | | - // Skip deleted revisions |
1899 | 1895 | $result = $dbr->select( array('flaggedrevs', 'revision'), |
1900 | 1896 | $selectColumns, |
1901 | 1897 | array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), |
1902 | | - 'fr_rev_id = rev_id', 'rev_page' => $title->getArticleID(), 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
| 1898 | + 'fr_rev_id = rev_id', 'rev_page' => $title->getArticleID(), |
| 1899 | + 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
1903 | 1900 | __METHOD__, |
1904 | 1901 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
1905 | | - |
1906 | | - // Do we have one? |
| 1902 | + # Do we have one? |
1907 | 1903 | if( $row = $dbr->fetchObject($result) ) { |
1908 | 1904 | $this->latestfound = true; |
1909 | 1905 | $this->latestrev = $row; |
— | — | @@ -1919,28 +1915,25 @@ |
1920 | 1916 | */ |
1921 | 1917 | public function getFlagsForRevision( $rev_id ) { |
1922 | 1918 | global $wgFlaggedRevTags; |
1923 | | - |
1924 | | - // Cached results? |
| 1919 | + # Cached results? |
1925 | 1920 | if( isset($this->flags[$rev_id]) && $this->flags[$rev_id] ) |
1926 | 1921 | return $this->revflags[$rev_id]; |
1927 | | - // Set all flags to zero |
| 1922 | + # Set all flags to zero |
1928 | 1923 | $flags = array(); |
1929 | 1924 | foreach( array_keys($wgFlaggedRevTags) as $tag ) { |
1930 | 1925 | $flags[$tag] = 0; |
1931 | 1926 | } |
1932 | | - |
| 1927 | + # Grab all the tags for this revision |
1933 | 1928 | $dbr = wfGetDB( DB_SLAVE ); |
1934 | | - // Grab all the tags for this revision |
1935 | | - $result = $dbr->select('flaggedrevtags', |
1936 | | - array('frt_dimension', 'frt_value'), |
1937 | | - array('frt_rev_id' => $rev_id), |
| 1929 | + $result = $dbr->select( 'flaggedrevtags', |
| 1930 | + array( 'frt_dimension', 'frt_value' ), |
| 1931 | + array( 'frt_rev_id' => $rev_id ), |
1938 | 1932 | __METHOD__ ); |
1939 | | - |
1940 | | - // Iterate through each tag result |
| 1933 | + # Iterate through each tag result |
1941 | 1934 | while( $row = $dbr->fetchObject($result) ) { |
1942 | 1935 | $flags[$row->frt_dimension] = $row->frt_value; |
1943 | 1936 | } |
1944 | | - // Try to cache results |
| 1937 | + # Try to cache results |
1945 | 1938 | $this->flags[$rev_id] = true; |
1946 | 1939 | $this->revflags[$rev_id] = $flags; |
1947 | 1940 | |
— | — | @@ -1971,8 +1964,7 @@ |
1972 | 1965 | $wgHooks['ArticleSaveComplete'][] = array($wgFlaggedArticle, 'autoPromoteUser'); |
1973 | 1966 | # Adds table link references to include ones from the stable version |
1974 | 1967 | $wgHooks['LinksUpdateConstructed'][] = array($wgFlaggedArticle, 'extraLinksUpdate'); |
1975 | | -# Check on undelete/delete/revisiondelete for changes to stable version |
1976 | | -$wgHooks['ArticleDeleteComplete'][] = array($wgFlaggedArticle, 'articleLinksUpdate'); |
| 1968 | +# Check on undelete/merge/revisiondelete for changes to stable version |
1977 | 1969 | $wgHooks['ArticleUndelete'][] = array($wgFlaggedArticle, 'articleLinksUpdate2'); |
1978 | 1970 | $wgHooks['ArticleRevisionVisiblitySet'][] = array($wgFlaggedArticle, 'articleLinksUpdate2'); |
1979 | 1971 | $wgHooks['ArticleMergeComplete'][] = array($wgFlaggedArticle, 'articleLinksUpdate'); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage_body.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | $this->oldid = $wgRequest->getIntOrNull( 'oldid' ); |
43 | 43 | // Must be a valid content page |
44 | 44 | $this->page = Title::newFromUrl( $this->target ); |
45 | | - if( !$this->target || !$this->oldid || !FlaggedRevs::isReviewable( $this->page ) ) { |
| 45 | + if( !$this->target || !$this->oldid || !$wgFlaggedRevs->isReviewable( $this->page ) ) { |
46 | 46 | $wgOut->addHTML( wfMsgExt('revreview-main',array('parse')) ); |
47 | 47 | return; |
48 | 48 | } |
— | — | @@ -232,10 +232,9 @@ |
233 | 233 | } |
234 | 234 | |
235 | 235 | function submit( $request ) { |
236 | | - global $wgOut, $wgUser; |
237 | | - |
238 | | - $approved = false; |
| 236 | + global $wgOut, $wgUser, $wgFlaggedRevs; |
239 | 237 | # If all values are set to zero, this has been unapproved |
| 238 | + $approved = false; |
240 | 239 | foreach( $this->dims as $quality => $value ) { |
241 | 240 | if( $value ) { |
242 | 241 | $approved = true; |
— | — | @@ -251,7 +250,7 @@ |
252 | 251 | return; |
253 | 252 | } |
254 | 253 | } else { |
255 | | - $frev = FlaggedRevs::getFlaggedRev( $this->oldid ); |
| 254 | + $frev = $wgFlaggedRevs->getFlaggedRev( $this->oldid ); |
256 | 255 | // If we can't find this flagged rev, return to page??? |
257 | 256 | if( is_null($frev) ) { |
258 | 257 | $wgOut->redirect( $this->page->escapeLocalUrl() ); |
— | — | @@ -278,7 +277,7 @@ |
279 | 278 | * Adds or updates the flagged revision table for this page/id set |
280 | 279 | */ |
281 | 280 | function approveRevision( $rev=NULL, $notes='' ) { |
282 | | - global $wgUser, $wgFlaggedRevsWatch, $wgParser; |
| 281 | + global $wgUser, $wgFlaggedRevsWatch, $wgParser, $wgFlaggedRevs; |
283 | 282 | // Skip null edits |
284 | 283 | if( is_null($rev) ) |
285 | 284 | return false; |
— | — | @@ -286,8 +285,8 @@ |
287 | 286 | $title = $rev->getTitle(); |
288 | 287 | |
289 | 288 | $quality = 0; |
290 | | - if( FlaggedRevs::isQuality($this->dims) ) { |
291 | | - $quality = FlaggedRevs::isPristine($this->dims) ? 2 : 1; |
| 289 | + if( $wgFlaggedRevs->isQuality($this->dims) ) { |
| 290 | + $quality = $wgFlaggedRevs->isPristine($this->dims) ? 2 : 1; |
292 | 291 | } |
293 | 292 | // Our flags |
294 | 293 | $flagset = array(); |
— | — | @@ -361,13 +360,13 @@ |
362 | 361 | __METHOD__ ); |
363 | 362 | } |
364 | 363 | // Get the page text and resolve all templates |
365 | | - list($fulltext,$complete) = FlaggedRevs::expandText( $rev->getText(), $rev->getTitle(), $rev->getId() ); |
| 364 | + list($fulltext,$complete) = $wgFlaggedRevs->expandText( $rev->getText(), $rev->getTitle(), $rev->getId() ); |
366 | 365 | if( !$complete ) { |
367 | 366 | $dbw->rollback(); // All versions must be specified, 0 for none |
368 | 367 | return false; |
369 | 368 | } |
370 | 369 | # Compress $fulltext, passed by reference |
371 | | - $textFlags = FlaggedRevs::compressText( $fulltext ); |
| 370 | + $textFlags = $wgFlaggedRevs->compressText( $fulltext ); |
372 | 371 | // Our review entry |
373 | 372 | $revset = array( |
374 | 373 | 'fr_rev_id' => $rev->getId(), |
— | — | @@ -559,7 +558,7 @@ |
560 | 559 | function showStableRevision( $frev ) { |
561 | 560 | global $wgParser, $wgLang, $wgUser, $wgOut, $wgFlaggedRevs; |
562 | 561 | // Get the revision |
563 | | - $frev = FlaggedRevs::getFlaggedRev( $this->oldid ); |
| 562 | + $frev = $wgFlaggedRevs->getFlaggedRev( $this->oldid ); |
564 | 563 | // Revision must exists |
565 | 564 | if( is_null($frev) ) { |
566 | 565 | $wgOut->showErrorPage( 'notargettitle', 'revnotfoundtext' ); |
— | — | @@ -592,11 +591,10 @@ |
593 | 592 | } |
594 | 593 | |
595 | 594 | function showStableList() { |
596 | | - global $wgOut, $wgUser, $wgLang; |
597 | | - |
| 595 | + global $wgOut, $wgUser, $wgLang, $wgFlaggedRevs; |
598 | 596 | // Must be a valid page/Id |
599 | 597 | $page = Title::newFromUrl( $this->page ); |
600 | | - if( is_null($page) || !FlaggedRevs::isReviewable( $page ) ) { |
| 598 | + if( is_null($page) || !$wgFlaggedRevs->isReviewable( $page ) ) { |
601 | 599 | $wgOut->showErrorPage('notargettitle', 'allpagesbadtitle' ); |
602 | 600 | return; |
603 | 601 | } |