Merge "Exclude redirects from Special:Fewestrevisions"
[lhc/web/wiklou.git] / includes / api / ApiExpandTemplates.php
index 562bcdf..851373d 100644 (file)
@@ -86,7 +86,6 @@ class ApiExpandTemplates extends ApiBase {
                $result = $this->getResult();
 
                // Parse text
-               global $wgParser;
                $options = ParserOptions::newFromContext( $this->getContext() );
 
                if ( $params['includecomments'] ) {
@@ -100,9 +99,10 @@ class ApiExpandTemplates extends ApiBase {
 
                $retval = [];
 
+               $parser = MediaWikiServices::getInstance()->getParser();
                if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
-                       $wgParser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS );
-                       $dom = $wgParser->preprocessToDom( $params['text'] );
+                       $parser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS );
+                       $dom = $parser->preprocessToDom( $params['text'] );
                        if ( is_callable( [ $dom, 'saveXML' ] ) ) {
                                $xml = $dom->saveXML();
                        } else {
@@ -121,14 +121,14 @@ class ApiExpandTemplates extends ApiBase {
                // if they didn't want any output except (probably) the parse tree,
                // then don't bother actually fully expanding it
                if ( $prop || $params['prop'] === null ) {
-                       $wgParser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS );
-                       $frame = $wgParser->getPreprocessor()->newFrame();
-                       $wikitext = $wgParser->preprocess( $params['text'], $titleObj, $options, $revid, $frame );
+                       $parser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS );
+                       $frame = $parser->getPreprocessor()->newFrame();
+                       $wikitext = $parser->preprocess( $params['text'], $titleObj, $options, $revid, $frame );
                        if ( $params['prop'] === null ) {
                                // the old way
                                ApiResult::setContentValue( $retval, 'wikitext', $wikitext );
                        } else {
-                               $p_output = $wgParser->getOutput();
+                               $p_output = $parser->getOutput();
                                if ( isset( $prop['categories'] ) ) {
                                        $categories = $p_output->getCategories();
                                        if ( $categories ) {
@@ -162,7 +162,8 @@ class ApiExpandTemplates extends ApiBase {
                                }
                                if ( isset( $prop['modules'] ) ) {
                                        $retval['modules'] = array_values( array_unique( $p_output->getModules() ) );
-                                       $retval['modulescripts'] = array_values( array_unique( $p_output->getModuleScripts() ) );
+                                       // Deprecated since 1.32 (T188689)
+                                       $retval['modulescripts'] = [];
                                        $retval['modulestyles'] = array_values( array_unique( $p_output->getModuleStyles() ) );
                                }
                                if ( isset( $prop['jsconfigvars'] ) ) {