X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fapi%2FApiExpandTemplates.php;h=851373d5e329d5ff1255bcaa56737c58470d86bb;hb=4fbbfcb955e85267498de684ff96e7fbb7d90545;hp=22f52356f205503e23c00febac0a792289318adb;hpb=8b26fc816ff5518726db80f518ad08460845ec6e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiExpandTemplates.php b/includes/api/ApiExpandTemplates.php index 22f52356f2..851373d5e3 100644 --- a/includes/api/ApiExpandTemplates.php +++ b/includes/api/ApiExpandTemplates.php @@ -86,7 +86,6 @@ class ApiExpandTemplates extends ApiBase { $result = $this->getResult(); // Parse text - global $wgParser; $options = ParserOptions::newFromContext( $this->getContext() ); if ( $params['includecomments'] ) { @@ -100,9 +99,10 @@ class ApiExpandTemplates extends ApiBase { $retval = []; + $parser = MediaWikiServices::getInstance()->getParser(); if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) { - $wgParser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS ); - $dom = $wgParser->preprocessToDom( $params['text'] ); + $parser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS ); + $dom = $parser->preprocessToDom( $params['text'] ); if ( is_callable( [ $dom, 'saveXML' ] ) ) { $xml = $dom->saveXML(); } else { @@ -121,14 +121,14 @@ class ApiExpandTemplates extends ApiBase { // if they didn't want any output except (probably) the parse tree, // then don't bother actually fully expanding it if ( $prop || $params['prop'] === null ) { - $wgParser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS ); - $frame = $wgParser->getPreprocessor()->newFrame(); - $wikitext = $wgParser->preprocess( $params['text'], $titleObj, $options, $revid, $frame ); + $parser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS ); + $frame = $parser->getPreprocessor()->newFrame(); + $wikitext = $parser->preprocess( $params['text'], $titleObj, $options, $revid, $frame ); if ( $params['prop'] === null ) { // the old way ApiResult::setContentValue( $retval, 'wikitext', $wikitext ); } else { - $p_output = $wgParser->getOutput(); + $p_output = $parser->getOutput(); if ( isset( $prop['categories'] ) ) { $categories = $p_output->getCategories(); if ( $categories ) {