Marcoil has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/215874

Change subject: Expose ResourceLoader modules in action=expandtemplates
......................................................................

Expose ResourceLoader modules in action=expandtemplates

Adds a 'modules' prop to action=expandtemplates that outputs the
modules added to ResourceLoader by extensions and parser functions.

This is needed by Parsoid to correctly include all modules used by
parser functions.

Based on I5c3ccb25385e57633639bb0c7e6f562eb58b05a2 by @Jackmcbarn.

Bug: T69540
Change-Id: Iaf58c66c987a318c0dd1ee2b81774106c40e7561
---
M includes/api/ApiExpandTemplates.php
M includes/api/i18n/en.json
2 files changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/74/215874/1

diff --git a/includes/api/ApiExpandTemplates.php 
b/includes/api/ApiExpandTemplates.php
index be1a695..34d549a 100644
--- a/includes/api/ApiExpandTemplates.php
+++ b/includes/api/ApiExpandTemplates.php
@@ -142,6 +142,15 @@
                                if ( isset( $prop['wikitext'] ) ) {
                                        $retval['wikitext'] = $wikitext;
                                }
+                               if ( isset( $prop['modules'] ) ) {
+                                       $p_output = $wgParser->getOutput();
+                                       $retval['modules'] = array_values( 
array_unique( $p_output->getModules() ) );
+                                       $retval['modulescripts'] = 
array_values( array_unique( $p_output->getModuleScripts() ) );
+                                       $retval['modulestyles'] = array_values( 
array_unique( $p_output->getModuleStyles() ) );
+                                       // To be removed in 1.27
+                                       $retval['modulemessages'] = array();
+                                       $this->setWarning( 'modulemessages is 
deprecated since MediaWiki 1.26' );
+                               }
                        }
                }
                ApiResult::setSubelementsList( $retval, array( 'wikitext', 
'parsetree' ) );
@@ -167,6 +176,7 @@
                                        'properties',
                                        'volatile',
                                        'ttl',
+                                       'modules',
                                        'parsetree',
                                ),
                                ApiBase::PARAM_ISMULTI => true,
diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json
index f3faf48..8e19ec4 100644
--- a/includes/api/i18n/en.json
+++ b/includes/api/i18n/en.json
@@ -121,7 +121,7 @@
        "apihelp-expandtemplates-param-title": "Title of page.",
        "apihelp-expandtemplates-param-text": "Wikitext to convert.",
        "apihelp-expandtemplates-param-revid": "Revision ID, for 
<nowiki>{{REVISIONID}}</nowiki> and similar variables.",
-       "apihelp-expandtemplates-param-prop": "Which pieces of information to 
get:\n;wikitext:The expanded wikitext.\n;categories:Any categories present in 
the input that are not represented in the wikitext output.\n;properties:Page 
properties defined by expanded magic words in the wikitext.\n;volatile:Whether 
the output is volatile and should not be reused elsewhere within the 
page.\n;ttl:The maximum time after which caches of the result should be 
invalidated.\n;parsetree:The XML parse tree of the input.\nNote that if no 
values are selected, the result will contain the wikitext, but the output will 
be in a deprecated format.",
+       "apihelp-expandtemplates-param-prop": "Which pieces of information to 
get:\n;wikitext:The expanded wikitext.\n;categories:Any categories present in 
the input that are not represented in the wikitext output.\n;properties:Page 
properties defined by expanded magic words in the wikitext.\n;volatile:Whether 
the output is volatile and should not be reused elsewhere within the 
page.\n;ttl:The maximum time after which caches of the result should be 
invalidated.\n;modules:Any ResourceLoader modules that parser functions have 
requested be added to the output.\n;parsetree:The XML parse tree of the 
input.\nNote that if no values are selected, the result will contain the 
wikitext, but the output will be in a deprecated format.",
        "apihelp-expandtemplates-param-includecomments": "Whether to include 
HTML comments in the output.",
        "apihelp-expandtemplates-param-generatexml": "Generate XML parse tree 
(replaced by $1prop=parsetree).",
        "apihelp-expandtemplates-example-simple": "Expand the wikitext 
<kbd><nowiki>{{Project:Sandbox}}</nowiki></kbd>.",

-- 
To view, visit https://gerrit.wikimedia.org/r/215874
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf58c66c987a318c0dd1ee2b81774106c40e7561
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Marcoil <marc...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to