DAT-2876 switch to internal parsing to prevent hooks errors

This commit is contained in:
idradm 2015-06-10 13:55:14 +02:00
parent 7cbfad1d19
commit 0396b38175

View file

@ -14,7 +14,9 @@ class MediaWikiParserService implements ExternalParser {
/**
* Method used for parsing wikitext provided through variable
*
* @param $wikitext
*
* @return mixed
*/
public function parse( $wikitext ) {
@ -23,15 +25,19 @@ class MediaWikiParserService implements ExternalParser {
//fix for first item list elements
$wikitext = "\n" . $wikitext;
}
$parsedText = $this->parser->parse( $wikitext, $this->getParserTitle(), $this->getParserOptions(),
false, false )->getText();
$output = $this->parser->internalParse( $wikitext, false, $this->frame );
$this->parser->replaceLinkHolders( $output );
wfProfileOut( __METHOD__ );
return $parsedText;
return $output;
}
/**
* Method used for parsing wikitext provided in infobox that might contain variables
*
* @param $wikitext
*
* @return string HTML outcome
*/
public function parseRecursive( $wikitext ) {
@ -42,16 +48,19 @@ class MediaWikiParserService implements ExternalParser {
$newlinesstripped = preg_replace( '|[\n\r]|Us', '', $ready );
$marksstripped = preg_replace( '|{{{.*}}}|Us', '', $newlinesstripped );
wfProfileOut( __METHOD__ );
return $marksstripped;
}
public function replaceVariables( $wikitext ) {
$output = $this->parser->replaceVariables( $wikitext, $this->frame );
return $output;
}
/**
* Add image to parser output for later usage
*
* @param string $title
*/
public function addImage( $title ) {
@ -68,6 +77,7 @@ class MediaWikiParserService implements ExternalParser {
private function getParserOptions() {
$options = $this->parser->getOptions();
$options->enableLimitReport( false );
return $options;
}
}