r69307 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69306‎ | r69307 | r69308 >
Date:16:45, 13 July 2010
Author:aaron
Status:deferred
Tags:
Comment:
* Dependency inject $frev into stabilizeParserOutput
* parseStableText/expandStableText cleanups
Modified paths:
  • /trunk/extensions/FlaggedRevs/FRInclusionManager.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -483,18 +483,21 @@
484484 */
485485 public static function expandText( Title $title, $text, $id ) {
486486 global $wgParser;
487 - $options = self::makeParserOptions(); // default options
488487 # Notify Parser if includes should be stabilized
489488 $resetManager = false;
490489 $incManager = FRInclusionManager::singleton();
491 - if ( self::inclusionSetting() != FR_INCLUDES_CURRENT ) {
 490+ if ( $id && self::inclusionSetting() != FR_INCLUDES_CURRENT ) {
492491 # Use FRInclusionManager to do the template/file version query
493492 # up front unless the versions are already specified there...
494 - if ( $id && !$incManager->parserOutputIsStabilized( $id ) ) {
495 - $incManager->stabilizeParserOutput( $title, $id );
496 - $resetManager = true; // need to reset when done
 493+ if ( !$incManager->parserOutputIsStabilized() ) {
 494+ $frev = FlaggedRevision::newFromTitle( $title, $id );
 495+ if ( $frev ) {
 496+ $incManager->stabilizeParserOutput( $title, $frev );
 497+ $resetManager = true; // need to reset when done
 498+ }
497499 }
498500 }
 501+ $options = self::makeParserOptions(); // default options
499502 $outputText = $wgParser->preprocess( $text, $title, $options, $id );
500503 $out = $wgParser->mOutput;
501504 # Stable parse done!
@@ -514,19 +517,22 @@
515518 */
516519 public static function parseStableText( Title $title, $text, $id ) {
517520 global $wgParser;
518 - $options = self::makeParserOptions(); // default options
519521 # Notify Parser if includes should be stabilized
520522 $resetManager = false;
521523 $incManager = FRInclusionManager::singleton();
522 - if ( self::inclusionSetting() != FR_INCLUDES_CURRENT ) {
 524+ if ( $id && self::inclusionSetting() != FR_INCLUDES_CURRENT ) {
523525 # Use FRInclusionManager to do the template/file version query
524526 # up front unless the versions are already specified there...
525 - if ( $id && !$incManager->parserOutputIsStabilized( $id ) ) {
526 - $incManager->stabilizeParserOutput( $title, $id );
527 - $resetManager = true; // need to reset when done
 527+ if ( !$incManager->parserOutputIsStabilized() ) {
 528+ $frev = FlaggedRevision::newFromTitle( $title, $id );
 529+ if ( $frev ) {
 530+ $incManager->stabilizeParserOutput( $title, $frev );
 531+ $resetManager = true; // need to reset when done
 532+ }
528533 }
529534 }
530535 # Parse the new body, wikitext -> html
 536+ $options = self::makeParserOptions(); // default options
531537 $parserOut = $wgParser->parse( $text, $title, $options, true, true, $id );
532538 # Stable parse done!
533539 if ( $resetManager ) {
Index: trunk/extensions/FlaggedRevs/FRInclusionManager.php
@@ -66,21 +66,18 @@
6767 * (c) Load their stable version counterparts (avoids DB hits)
6868 * Note: Used when calling FlaggedRevs::parseStableText().
6969 * @param Title $title
70 - * @param int $revId
 70+ * @param FlaggedRevision $frev
7171 * @return void
7272 */
73 - public function stabilizeParserOutput( Title $title, $revId ) {
 73+ public function stabilizeParserOutput( Title $title, FlaggedRevision $frev ) {
7474 $tRevVersions = $fRevVersions = array(); // review time versions
7575 $tStbVersions = $fStbVersions = array(); // stable versions
76 - $frev = FlaggedRevision::newFromTitle( $title, $revId );
77 - if ( $frev ) {
78 - $tRevVersions = $frev->getTemplateVersions();
79 - $fRevVersions = $frev->getFileVersions();
80 - # We can preload *most* of the stable version IDs the parser will need...
81 - if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE ) {
82 - $tStbVersions = $frev->getStableTemplateVersions();
83 - $fStbVersions = $frev->getStableFileVersions();
84 - }
 76+ $tRevVersions = $frev->getTemplateVersions();
 77+ $fRevVersions = $frev->getFileVersions();
 78+ # We can preload *most* of the stable version IDs the parser will need...
 79+ if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE ) {
 80+ $tStbVersions = $frev->getStableTemplateVersions();
 81+ $fStbVersions = $frev->getStableFileVersions();
8582 }
8683 $this->setReviewedVersions( $tRevVersions, $fRevVersions );
8784 $this->setStableVersionCache( $tStbVersions, $fStbVersions );

Status & tagging log