From 0396b38175de0fea0c5ce6ed73a75d614bc5fe06 Mon Sep 17 00:00:00 2001 From: idradm Date: Wed, 10 Jun 2015 13:55:14 +0200 Subject: [PATCH] DAT-2876 switch to internal parsing to prevent hooks errors --- services/Parser/MediaWikiParserService.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/services/Parser/MediaWikiParserService.php b/services/Parser/MediaWikiParserService.php index 9564cbc..6d186d3 100644 --- a/services/Parser/MediaWikiParserService.php +++ b/services/Parser/MediaWikiParserService.php @@ -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; } }