r34544 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34543‎ | r34544 | r34545 >
Date:01:06, 10 May 2008
Author:aaron
Status:old
Tags:
Comment:
Add getTextForParse() accessor
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -518,12 +518,7 @@
519519 $flaggedOutput = FlaggedRevs::getPageCache( $article );
520520 if( $flaggedOutput==false ) {
521521 global $wgUseStableTemplates;
522 - if( $wgUseStableTemplates ) {
523 - $rev = Revision::newFromId( $frev->getRevId() );
524 - $text = $rev->getText();
525 - } else {
526 - $text = $frev->getExpandedText();
527 - }
 522+ $text = $frev->getTextForParse();
528523 $flaggedOutput = FlaggedRevs::parseStableText( $article, $text, $frev->getRevId() );
529524 # Update the stable version cache
530525 FlaggedRevs::updatePageCache( $article, $flaggedOutput );
@@ -1388,12 +1383,7 @@
13891384 # Try stable version cache. This should be updated before this is called.
13901385 $parserOut = self::getPageCache( $article );
13911386 if( $parserOut==false ) {
1392 - if( $wgUseStableTemplates ) {
1393 - $rev = Revision::newFromId( $sv->getRevId() );
1394 - $text = $rev->getText();
1395 - } else {
1396 - $text = $sv->getExpandedText();
1397 - }
 1387+ $text = $sv->getTextForParse();
13981388 # Parse the text
13991389 $parserOut = self::parseStableText( $article, $text, $sv->getRevId() );
14001390 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -123,6 +123,21 @@
124124 $this->loadText(); // load if not loaded
125125 return $this->mText;
126126 }
 127+
 128+ /**
 129+ * @returns mixed (string/false) expanded text or revision text.
 130+ * Depends on whether $wgUseStableTemplates is on or not.
 131+ */
 132+ public function getTextForParse() {
 133+ global $wgUseStableTemplates;
 134+ if( $wgUseStableTemplates ) {
 135+ $rev = Revision::newFromId( $this->getRevId() );
 136+ $text = $rev->getText();
 137+ } else {
 138+ $text = $this->getExpandedText();
 139+ }
 140+ return $text;
 141+ }
127142
128143 /**
129144 * @returns Integer the user ID of the reviewer

Status & tagging log