ApiPageSet may contain entries where the 'from' value is percent-encoded as
the raw value cannot be represented in a valid API response. These are
indicated by a 'fromencoded' boolean alongside the existing 'from' parameter.
+* (T28680) action=paraminfo can now return info about all submodules of a
+ module without listing them all explicitly.
=== Action API internal changes in 1.28 ===
* Added a new hook, 'ApiMakeParserOptions', to allow extensions to better
$this->context->setLanguage( $this->getMain()->getLanguage() );
if ( is_array( $params['modules'] ) ) {
- $modules = $params['modules'];
+ $modules = [];
+ foreach ( $params['modules'] as $path ) {
+ if ( $path === '*' || $path === '**' ) {
+ $path = "main+$path";
+ }
+ if ( substr( $path, -2 ) === '+*' || substr( $path, -2 ) === ' *' ) {
+ $submodules = true;
+ $path = substr( $path, 0, -2 );
+ $recursive = false;
+ } elseif ( substr( $path, -3 ) === '+**' || substr( $path, -3 ) === ' **' ) {
+ $submodules = true;
+ $path = substr( $path, 0, -3 );
+ $recursive = true;
+ } else {
+ $submodules = false;
+ }
+
+ if ( $submodules ) {
+ try {
+ $module = $this->getModuleFromPath( $path );
+ } catch ( UsageException $ex ) {
+ $this->setWarning( $ex->getMessage() );
+ }
+ $submodules = $this->listAllSubmodules( $module, $recursive );
+ if ( $submodules ) {
+ $modules = array_merge( $modules, $submodules );
+ } else {
+ $this->setWarning( "Module $path has no submodules" );
+ }
+ } else {
+ $modules[] = $path;
+ }
+ }
} else {
$modules = [];
}
$formatModules = [];
}
+ $modules = array_unique( $modules );
+
$res = [];
foreach ( $modules as $m ) {
$result->addValue( null, $this->getModuleName(), $res );
}
+ /**
+ * List all submodules of a module
+ * @param ApiBase $module
+ * @param boolean $recursive
+ * @return string[]
+ */
+ private function listAllSubmodules( ApiBase $module, $recursive ) {
+ $manager = $module->getModuleManager();
+ if ( $manager ) {
+ $paths = [];
+ $names = $manager->getNames();
+ sort( $names );
+ foreach ( $names as $name ) {
+ $submodule = $manager->getModule( $name );
+ $paths[] = $submodule->getModulePath();
+ if ( $recursive && $submodule->getModuleManager() ) {
+ $paths = array_merge( $paths, $this->listAllSubmodules( $submodule, $recursive ) );
+ }
+ }
+ }
+ return $paths;
+ }
+
/**
* @param array $res Result array
* @param string $key Result key
protected function getExamplesMessages() {
return [
- 'action=paraminfo&modules=parse|phpfm|query+allpages|query+siteinfo'
+ 'action=paraminfo&modules=parse|phpfm|query%2Ballpages|query%2Bsiteinfo'
=> 'apihelp-paraminfo-example-1',
+ 'action=paraminfo&modules=query%2B*'
+ => 'apihelp-paraminfo-example-2',
];
}
"apihelp-options-example-complex": "Reset all preferences, then set <kbd>skin</kbd> and <kbd>nickname</kbd>.",
"apihelp-paraminfo-description": "Obtain information about API modules.",
- "apihelp-paraminfo-param-modules": "List of module names (values of the <var>action</var> and <var>format</var> parameters, or <kbd>main</kbd>). Can specify submodules with a <kbd>+</kbd>.",
+ "apihelp-paraminfo-param-modules": "List of module names (values of the <var>action</var> and <var>format</var> parameters, or <kbd>main</kbd>). Can specify submodules with a <kbd>+</kbd>, or all submodules with <kbd>+*</kbd>, or all submodules recursively with <kbd>+**</kbd>.",
"apihelp-paraminfo-param-helpformat": "Format of help strings.",
"apihelp-paraminfo-param-querymodules": "List of query module names (value of <var>prop</var>, <var>meta</var> or <var>list</var> parameter). Use <kbd>$1modules=query+foo</kbd> instead of <kbd>$1querymodules=foo</kbd>.",
"apihelp-paraminfo-param-mainmodule": "Get information about the main (top-level) module as well. Use <kbd>$1modules=main</kbd> instead.",
"apihelp-paraminfo-param-pagesetmodule": "Get information about the pageset module (providing titles= and friends) as well.",
"apihelp-paraminfo-param-formatmodules": "List of format module names (value of <var>format</var> parameter). Use <var>$1modules</var> instead.",
"apihelp-paraminfo-example-1": "Show info for <kbd>[[Special:ApiHelp/parse|action=parse]]</kbd>, <kbd>[[Special:ApiHelp/jsonfm|format=jsonfm]]</kbd>, <kbd>[[Special:ApiHelp/query+allpages|action=query&list=allpages]]</kbd>, and <kbd>[[Special:ApiHelp/query+siteinfo|action=query&meta=siteinfo]]</kbd>.",
+ "apihelp-paraminfo-example-2": "Show info for all submodules of <kbd>[[Special:ApiHelp/query|action=query]]</kbd>.",
"apihelp-parse-description": "Parses content and returns parser output.\n\nSee the various prop-modules of <kbd>[[Special:ApiHelp/query|action=query]]</kbd> to get information from the current version of a page.\n\nThere are several ways to specify the text to parse:\n# Specify a page or revision, using <var>$1page</var>, <var>$1pageid</var>, or <var>$1oldid</var>.\n# Specify content explicitly, using <var>$1text</var>, <var>$1title</var>, and <var>$1contentmodel</var>.\n# Specify only a summary to parse. <var>$1prop</var> should be given an empty value.",
"apihelp-parse-param-title": "Title of page the text belongs to. If omitted, <var>$1contentmodel</var> must be specified, and [[API]] will be used as the title.",
"apihelp-paraminfo-param-pagesetmodule": "{{doc-apihelp-param|paraminfo|pagesetmodule}}",
"apihelp-paraminfo-param-formatmodules": "{{doc-apihelp-param|paraminfo|formatmodules}}",
"apihelp-paraminfo-example-1": "{{doc-apihelp-example|paraminfo}}",
+ "apihelp-paraminfo-example-2": "{{doc-apihelp-example|paraminfo}}",
"apihelp-parse-description": "{{doc-apihelp-description|parse}}",
"apihelp-parse-param-title": "{{doc-apihelp-param|parse|title}}",
"apihelp-parse-param-text": "{{doc-apihelp-param|parse|text}}",