r73817 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73816‎ | r73817 | r73818 >
Date:16:13, 27 September 2010
Author:platonides
Status:resolved (Comments)
Tags:
Comment:
Rename a variable, add some comment, spacing, and move article parsing with article output, instead of getting the content at the top of the functions, determine &$tag in the middle and then reevaluate the $redirHtml branch for output.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1440,10 +1440,10 @@
14411441 return true;
14421442 }
14431443
1444 - public static function onArticleViewHeader( &$article, &$outputDone, &$pcache ) {
 1444+ public static function onArticleViewHeader( &$article, &$outputDone, &$useParserCache ) {
14451445 $view = FlaggedArticleView::singleton();
1446 - $view->addStableLink( $outputDone, $pcache );
1447 - $view->setPageContent( $outputDone, $pcache );
 1446+ $view->addStableLink( $outputDone, $useParserCache );
 1447+ $view->setPageContent( $outputDone, $useParserCache );
14481448 return true;
14491449 }
14501450
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -223,7 +223,7 @@
224224 * Adds stable version status/info tags and notes
225225 * Adds a quick review form on the bottom if needed
226226 */
227 - public function setPageContent( &$outputDone, &$pcache ) {
 227+ public function setPageContent( &$outputDone, &$useParserCache ) {
228228 global $wgRequest, $wgOut, $wgLang, $wgContLang;
229229 $this->load();
230230 # Only trigger on article view for content pages, not for protect/delete/hist...
@@ -267,7 +267,7 @@
268268 $wgOut->returnToMain( false, $this->article->getTitle() );
269269 # Tell MW that parser output is done
270270 $outputDone = true;
271 - $pcache = false;
 271+ $useParserCache = false;
272272 return true;
273273 }
274274 // Is the page config altered?
@@ -291,13 +291,13 @@
292292 if ( $old ) {
293293 $this->showOldReviewedVersion( $srev, $frev, $tag, $prot );
294294 $outputDone = true; # Tell MW that parser output is done
295 - $pcache = false;
 295+ $useParserCache = false;
296296 // Stable version requested by ID or relevant conditions met to
297297 // to override page view.
298298 } else if ( $stable || $this->pageOverride() ) {
299 - $this->showStableVersion( $srev, $tag, $prot );
 299+ $this->showStableVersion( $srev, $tag, $prot );
300300 $outputDone = true; # Tell MW that parser output is done
301 - $pcache = false;
 301+ $useParserCache = false;
302302 // Looking at some specific old revision (&oldid=x) or if FlaggedRevs is not
303303 // set to override given the relevant conditions (like &stable=0) or there
304304 // is no stable version.
@@ -494,14 +494,7 @@
495495 # Get quality level
496496 $quality = FlaggedRevs::isQuality( $flags );
497497 $pristine = FlaggedRevs::isPristine( $flags );
498 - $text = $frev->getRevText();
499 - # Check if this is a redirect...
500 - $redirHtml = $this->getRedirectHtml( $text );
501 - if ( $redirHtml == '' ) {
502 - $parserOptions = FlaggedRevs::makeParserOptions();
503 - $parserOut = FlaggedRevs::parseStableText(
504 - $this->article->getTitle(), $text, $frev->getRevId(), $parserOptions );
505 - }
 498+
506499 # Construct some tagging for non-printable outputs. Note that the pending
507500 # notice has all this info already, so don't do this if we added that already.
508501 if ( !$wgOut->isPrintable() ) {
@@ -541,12 +534,21 @@
542535 }
543536 }
544537 }
545 - # Output HTML
 538+ # Load the review notes which will be shown by onSkinAfterContent
546539 $this->setReviewNotes( $frev );
547 - if ( $redirHtml != '' ) {
 540+
 541+ # Check if this is a redirect...
 542+ $text = $frev->getRevText();
 543+ $redirHtml = $this->getRedirectHtml( $text );
 544+
 545+ # Parse and output HTML
 546+ if ( $redirHtml == '' ) {
 547+ $parserOptions = FlaggedRevs::makeParserOptions();
 548+ $parserOut = FlaggedRevs::parseStableText(
 549+ $this->article->getTitle(), $text, $frev->getRevId(), $parserOptions );
 550+ $this->addParserOutput( $parserOut );
 551+ } else {
548552 $wgOut->addHtml( $redirHtml );
549 - } else {
550 - $this->addParserOutput( $parserOut );
551553 }
552554 }
553555
@@ -567,26 +569,7 @@
568570 # Get quality level
569571 $quality = FlaggedRevs::isQuality( $flags );
570572 $pristine = FlaggedRevs::isPristine( $flags );
571 - # Get parsed stable version
572 - $redirHtml = '';
573 - $parserOut = FlaggedRevs::getPageCache( $this->article, $wgUser );
574 - if ( !$parserOut ) {
575 - $text = $srev->getRevText();
576 - # Check if this is a redirect...
577 - $redirHtml = $this->getRedirectHtml( $text );
578 - # Don't parse redirects, use separate handling...
579 - if ( $redirHtml == '' ) {
580 - # Get the new stable output
581 - $parserOptions = FlaggedRevs::makeParserOptions();
582 - $parserOut = FlaggedRevs::parseStableText(
583 - $this->article->getTitle(), $text, $srev->getRevId(), $parserOptions );
584 - # Update the stable version cache & dependancies
585 - FlaggedRevs::updatePageCache( $this->article, $parserOptions, $parserOut );
586 - FlaggedRevs::updateCacheTracking( $this->article, $parserOut );
587 - } else {
588 - $parserOut = null;
589 - }
590 - }
 573+
591574 $synced = $this->article->stableVersionIsSynced();
592575 # Construct some tagging
593576 if ( !$wgOut->isPrintable() && !( $this->article->lowProfileUI() && $synced ) ) {
@@ -632,13 +615,31 @@
633616 }
634617 }
635618 }
636 - # Output HTML
 619+
 620+ # Load the review notes which will be shown by onSkinAfterContent
637621 $this->setReviewNotes( $srev );
638 - if ( $redirHtml != '' ) {
639 - $wgOut->addHtml( $redirHtml );
640 - } else {
641 - // $parserOut will not be null here
642 - $this->addParserOutput( $parserOut );
 622+
 623+ # Get parsed stable version and output HTML
 624+ $redirHtml = '';
 625+ $parserOut = FlaggedRevs::getPageCache( $this->article, $wgUser );
 626+ if ( !$parserOut ) {
 627+ $text = $srev->getRevText();
 628+ # Check if this is a redirect...
 629+ $redirHtml = $this->getRedirectHtml( $text );
 630+ # Don't parse redirects, use separate handling...
 631+ if ( $redirHtml == '' ) {
 632+ # Get the new stable output
 633+ $parserOptions = FlaggedRevs::makeParserOptions();
 634+ $parserOut = FlaggedRevs::parseStableText(
 635+ $this->article->getTitle(), $text, $srev->getRevId(), $parserOptions );
 636+ # Update the stable version cache & dependancies
 637+ FlaggedRevs::updatePageCache( $this->article, $parserOptions, $parserOut );
 638+ FlaggedRevs::updateCacheTracking( $this->article, $parserOut );
 639+
 640+ $this->addParserOutput( $parserOut );
 641+ } else {
 642+ $wgOut->addHtml( $redirHtml );
 643+ }
643644 }
644645 }
645646

Comments

#Comment by Aaron Schulz (talk | contribs)   00:43, 17 November 2010

Fixed in r76866.

Status & tagging log