installer: Replace the use of global $wgParser with services
authorDerick Alangi <alangiderick@gmail.com>
Sun, 3 Mar 2019 12:23:47 +0000 (13:23 +0100)
committerDerick Alangi <alangiderick@gmail.com>
Sun, 3 Mar 2019 14:05:16 +0000 (15:05 +0100)
global $wgParser was deprecated in 1.32 and services are used
instead to get the parser object via MediaWikiServices. Making
this replacement as we're avoiding globals.

Change-Id: I967a52c481bfcc83552053a03e88acb038810828

includes/installer/Installer.php
includes/installer/WebInstaller.php

index 3ac152e..bc3fe29 100644 (file)
@@ -686,10 +686,10 @@ abstract class Installer {
         * @return string
         */
        public function parse( $text, $lineStart = false ) {
-               global $wgParser;
+               $parser = MediaWikiServices::getInstance()->getParser();
 
                try {
-                       $out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
+                       $out = $parser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
                        $html = $out->getText( [
                                'enableSectionEditLinks' => false,
                                'unwrap' => true,
index cda8612..e1070c6 100644 (file)
@@ -140,9 +140,9 @@ class WebInstaller extends Installer {
                $this->request = $request;
 
                // Add parser hooks
-               global $wgParser;
-               $wgParser->setHook( 'downloadlink', [ $this, 'downloadLinkHook' ] );
-               $wgParser->setHook( 'doclink', [ $this, 'docLink' ] );
+               $parser = MediaWikiServices::getInstance()->getParser();
+               $parser->setHook( 'downloadlink', [ $this, 'downloadLinkHook' ] );
+               $parser->setHook( 'doclink', [ $this, 'docLink' ] );
        }
 
        /**