Merge "Print chained exceptions when maintenance script fails."
[lhc/web/wiklou.git] / maintenance / preprocessDump.php
index 25ef1a7..a62e019 100644 (file)
@@ -25,6 +25,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/dumpIterator.php';
 
 /**
@@ -40,8 +42,9 @@ class PreprocessDump extends DumpIterator {
        public $mPPNodeCount = 0;
 
        public function getStripList() {
-               global $wgParser;
-               return $wgParser->getStripList();
+               $parser = MediaWikiServices::getInstance()->getParser();
+
+               return $parser->getStripList();
        }
 
        public function __construct() {
@@ -55,7 +58,7 @@ class PreprocessDump extends DumpIterator {
        }
 
        public function checkOptions() {
-               global $wgParser, $wgParserConf, $wgPreprocessorCacheThreshold;
+               global $wgParserConf, $wgPreprocessorCacheThreshold;
 
                if ( !$this->hasOption( 'cache' ) ) {
                        $wgPreprocessorCacheThreshold = false;
@@ -66,10 +69,10 @@ class PreprocessDump extends DumpIterator {
                } elseif ( isset( $wgParserConf['preprocessorClass'] ) ) {
                        $name = $wgParserConf['preprocessorClass'];
                } else {
-                       $name = 'Preprocessor_DOM';
+                       $name = Preprocessor_DOM::class;
                }
 
-               $wgParser->firstCallInit();
+               MediaWikiServices::getInstance()->getParser()->firstCallInit();
                $this->mPreprocessor = new $name( $this );
        }
 
@@ -85,12 +88,13 @@ class PreprocessDump extends DumpIterator {
                }
 
                try {
-                       $this->mPreprocessor->preprocessToObj( strval( $content->getNativeData() ), 0 );
+                       $this->mPreprocessor->preprocessToObj( strval( $content->getText() ), 0 );
                } catch ( Exception $e ) {
-                       $this->error( "Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText() );
+                       $this->error( "Caught exception " . $e->getMessage() . " in "
+                               . $rev->getTitle()->getPrefixedText() );
                }
        }
 }
 
-$maintClass = "PreprocessDump";
+$maintClass = PreprocessDump::class;
 require_once RUN_MAINTENANCE_IF_MAIN;