r46905 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46904‎ | r46905 | r46906 >
Date:10:25, 6 February 2009
Author:aaron
Status:deferred
Tags:
Comment:
* Improve handling if $wgFlaggedRevValues isn't set
* Improve cache usage wrt sync checks
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -33,9 +33,9 @@
3434 # B/C, $levels is just an integer (minQL)
3535 } else {
3636 global $wgFlaggedRevPristine, $wgFlaggedRevValues;
37 - $minQL = $levels;
38 - $minPL = isset($wgFlaggedRevPristine) ? $wgFlaggedRevPristine : $wgFlaggedRevValues+1;
3937 $ratingLevels = isset($wgFlaggedRevValues) ? $wgFlaggedRevValues : 1;
 38+ $minQL = $levels; // an integer
 39+ $minPL = isset($wgFlaggedRevPristine) ? $wgFlaggedRevPristine : $ratingLevels+1;
4040 }
4141 # Set FlaggedRevs tags
4242 self::$dimensions[$tag] = array();
@@ -67,7 +67,6 @@
6868 self::$feedbackTags[$tag][$i] = "feedback-{$tag}-{$i}";
6969 }
7070 }
71 -
7271 self::$loaded = true;
7372 }
7473
@@ -538,13 +537,13 @@
539538 */
540539 public static function stableVersionIsSynced( $srev, $article, $stableOutput=null, $currentOutput=null ) {
541540 global $wgMemc, $wgEnableParserCache;
542 - # Must be the same revision
543 - if( $srev->getRevId() != $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) ) {
 541+ # Must be the same revision as the current
 542+ if( $srev->getRevId() < $article->getTitle()->getLatestRevID() ) {
544543 return false;
545544 }
546545 # Must have same file
547546 if( $article instanceof ImagePage && $article->getFile() ) {
548 - if( $srev->getFileTimestamp() != $article->getFile()->getTimestamp() ) {
 547+ if( $srev->getFileTimestamp() < $article->getFile()->getTimestamp() ) {
549548 return false;
550549 }
551550 }
@@ -560,7 +559,7 @@
561560 if( is_null($stableOutput) || !isset($stableOutput->fr_newestTemplateID) ) {
562561 # Get parsed stable version
563562 $stableOutput = self::getPageCache( $article );
564 - if( $stableOutput==false ) {
 563+ if( $stableOutput == false ) {
565564 $text = $srev->getRevText();
566565 $stableOutput = self::parseStableText( $article, $text, $srev->getRevId() );
567566 # Update the stable version cache
@@ -571,10 +570,21 @@
572571 global $wgUser, $wgParser;
573572 # Get parsed current version
574573 $parserCache = ParserCache::singleton();
575 - $currentOutput = $parserCache->get( $article, $wgUser );
 574+ $currentOutput = false;
576575 # If $text is set, then the stableOutput is new. In that case,
577576 # the current must also be new to avoid sync goofs.
578 - if( $currentOutput==false || isset($text) ) {
 577+ if( !isset($text) ) {
 578+ # Try anon user cache first...
 579+ if( $wgUser->getId() ) {
 580+ $anon = User::newFromId( 0 );
 581+ $currentOutput = $parserCache->get( $article, $anon );
 582+ }
 583+ # Cache for this user...
 584+ if( $currentOutput == false )
 585+ $currentOutput = $parserCache->get( $article, $wgUser );
 586+ }
 587+ # Regenerate the parser output as needed...
 588+ if( $currentOutput == false ) {
579589 $rev = Revision::newFromTitle( $article->getTitle() );
580590 $text = $rev ? $rev->getText() : false;
581591 $title = $article->getTitle();

Status & tagging log