X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialExpandTemplates.php;h=ef1b3d89f1f52f2e2e5a0545644832b38bb9af3f;hb=28d9e60182f33c507147f48b15566c653b890a3c;hp=619665bdb49fa7acf354046514fb3f6e508997b7;hpb=0770f85a0a293e6c7af6f1d3d3a1dbd2d13c1e09;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialExpandTemplates.php b/includes/specials/SpecialExpandTemplates.php index 619665bdb4..ef1b3d89f1 100644 --- a/includes/specials/SpecialExpandTemplates.php +++ b/includes/specials/SpecialExpandTemplates.php @@ -21,6 +21,8 @@ * @ingroup SpecialPage */ +use MediaWiki\MediaWikiServices; + /** * A special page that expands submitted templates, parser functions, * and variables, allowing easier debugging of these. @@ -53,8 +55,6 @@ class SpecialExpandTemplates extends SpecialPage { * @param string|null $subpage */ function execute( $subpage ) { - global $wgParser; - $this->setHeaders(); $this->addHelpLink( 'Help:ExpandTemplates' ); @@ -77,18 +77,21 @@ class SpecialExpandTemplates extends SpecialPage { $options->setTidy( true ); $options->setMaxIncludeSize( self::MAX_INCLUDE_SIZE ); + $parser = MediaWikiServices::getInstance()->getParser(); if ( $this->generateXML ) { - $wgParser->startExternalParse( $title, $options, Parser::OT_PREPROCESS ); - $dom = $wgParser->preprocessToDom( $input ); + $parser->startExternalParse( $title, $options, Parser::OT_PREPROCESS ); + $dom = $parser->preprocessToDom( $input ); if ( method_exists( $dom, 'saveXML' ) ) { + // @phan-suppress-next-line PhanUndeclaredMethod $xml = $dom->saveXML(); } else { + // @phan-suppress-next-line PhanUndeclaredMethod $xml = $dom->__toString(); } } - $output = $wgParser->preprocess( $input, $title, $options ); + $output = $parser->preprocess( $input, $title, $options ); } else { $this->removeComments = $request->getBool( 'wpRemoveComments', true ); $this->removeNowiki = $request->getBool( 'wpRemoveNowiki', false ); @@ -154,7 +157,6 @@ class SpecialExpandTemplates extends SpecialPage { * * @param string $title Value for context title field * @param string $input Value for input textbox - * @return string */ private function makeForm( $title, $input ) { $fields = [ @@ -247,11 +249,9 @@ class SpecialExpandTemplates extends SpecialPage { * @return ParserOutput */ private function generateHtml( Title $title, $text ) { - global $wgParser; - $popts = ParserOptions::newFromContext( $this->getContext() ); $popts->setTargetLanguage( $title->getPageLanguage() ); - return $wgParser->parse( $text, $title, $popts ); + return MediaWikiServices::getInstance()->getParser()->parse( $text, $title, $popts ); } /**