Merge "Allow users who are partially blocked to delete revisions."
[lhc/web/wiklou.git] / includes / specials / SpecialExpandTemplates.php
index 9ea5e08..a466f29 100644 (file)
@@ -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 );
@@ -246,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 );
        }
 
        /**
@@ -281,7 +282,7 @@ class SpecialExpandTemplates extends SpecialPage {
                        }
 
                        if ( $error ) {
-                               $out->wrapWikiMsg( "<div class='previewnote'>\n$1\n</div>", $error );
+                               $out->wrapWikiMsg( "<div class='previewnote errorbox'>\n$1\n</div>", $error );
                                return;
                        }
                }