$oldTidy = $popts->setTidy( $tidy );
$popts->setInterfaceMessage( (bool)$interface );
- $parserOutput = $wgParser->parse(
+ $parserOutput = $wgParser->getFreshParser()->parse(
$text, $title, $popts,
$linestart, true, $this->mRevisionId
);
$oldLang = $popts->setTargetLanguage( $language );
}
- $parserOutput = $wgParser->parse(
+ $parserOutput = $wgParser->getFreshParser()->parse(
$text, $this->getTitle(), $popts,
$linestart, true, $this->mRevisionId
);
return $html;
}
+
+ /**
+ * Return this parser if it is not doing anything, otherwise
+ * get a fresh parser. You can use this method by doing
+ * $myParser = $wgParser->getFreshParser(), or more simply
+ * $wgParser->getFreshParser()->parse( ... );
+ * if you're unsure if $wgParser is safe to use.
+ *
+ * @since 1.24
+ * @return Parser A parser object that is not parsing anything
+ */
+ public function getFreshParser() {
+ global $wgParserConf;
+ if ( $this->mInParse ) {
+ return new $wgParserConf['class']( $wgParserConf );
+ } else {
+ return $this;
+ }
+ }
}