r94480 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94479‎ | r94480 | r94481 >
Date:20:22, 14 August 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
Added Parser::recursivePreprocess(); like preprocess() but doesn't call startParse() so that it can be used inside a parse operation using the same context without having to mess with other functions

Simple use case (PHP 5.3+) that will work show the expand text passed to a <preprocess> tag:
$wgHooks['ParserFirstCallInit'][] = function( $parser ) {
$parser->setHook( 'preprocess', function( $text, $attr, $parser, $frame ) {
return $parser->recursivePreprocess( $text, $frame );
} );
return true;
};
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -511,6 +511,22 @@
512512 }
513513
514514 /**
 515+ * Recursive parser entry point that can be called from an extension tag
 516+ * hook.
 517+ *
 518+ * @param $text String: text to be expanded
 519+ * @param $frame PPFrame: The frame to use for expanding any template variables
 520+ * @return String
 521+ */
 522+ public function recursivePreprocess( $text, $frame = false ) {
 523+ wfProfileIn( __METHOD__ );
 524+ $text = $this->replaceVariables( $text, $frame );
 525+ $text = $this->mStripState->unstripBoth( $text );
 526+ wfProfileOut( __METHOD__ );
 527+ return $text;
 528+ }
 529+
 530+ /**
515531 * Process the wikitext for the ?preload= feature. (bug 5210)
516532 *
517533 * <noinclude>, <includeonly> etc. are parsed as for template transclusion,

Sign-offs

UserFlagDate
Nikerabbitinspected19:04, 15 August 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r108460Missing @since tags have a yet another victimnikerabbit19:11, 9 January 2012
r108461MFT r94480 for Translate extensionnikerabbit19:13, 9 January 2012

Comments

#Comment by 😂 (talk | contribs)   20:24, 14 August 2011

I <3 5.3 examples.

Status & tagging log