maintenance: Replace deprecated global $wgParser with getParser() service
authorDerick Alangi <alangiderick@gmail.com>
Sat, 9 Mar 2019 22:37:49 +0000 (23:37 +0100)
committerDerick Alangi <alangiderick@gmail.com>
Sat, 9 Mar 2019 23:35:42 +0000 (00:35 +0100)
$wgParser is deprecated and using globals should also be avoid. So, replacing
the use of global $wgParser by a mediawiki service.

Change-Id: I34b61338e500567773249c71da0a7125cfd50d02

maintenance/formatInstallDoc.php
maintenance/preprocessDump.php

index 3d34be1..160a20d 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/Maintenance.php';
 
 /**
@@ -61,10 +63,10 @@ class FormatInstallDoc extends Maintenance {
                $outText = InstallDocFormatter::format( $inText );
 
                if ( $this->hasOption( 'html' ) ) {
-                       global $wgParser;
+                       $parser = MediaWikiServices::getInstance()->getParser();
                        $opt = new ParserOptions;
                        $title = Title::newFromText( 'Text file' );
-                       $out = $wgParser->parse( $outText, $title, $opt );
+                       $out = $parser->parse( $outText, $title, $opt );
                        $outText = "<html><body>\n" . $out->getText() . "\n</body></html>\n";
                }
 
index f8526d0..75904d0 100644 (file)
@@ -25,6 +25,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/dumpIterator.php';
 
 /**
@@ -40,9 +42,9 @@ class PreprocessDump extends DumpIterator {
        public $mPPNodeCount = 0;
 
        public function getStripList() {
-               global $wgParser;
+               $parser = MediaWikiServices::getInstance()->getParser();
 
-               return $wgParser->getStripList();
+               return $parser->getStripList();
        }
 
        public function __construct() {