if ( $submodules ) {
try {
$module = $this->getModuleFromPath( $path );
- } catch ( UsageException $ex ) {
- $this->setWarning( $ex->getMessage() );
+ } catch ( ApiUsageException $ex ) {
+ foreach ( $ex->getStatusValue()->getErrors() as $error ) {
+ $this->addWarning( $error );
+ }
+ continue;
}
$submodules = $this->listAllSubmodules( $module, $recursive );
if ( $submodules ) {
$modules = array_merge( $modules, $submodules );
} else {
- $this->setWarning( "Module $path has no submodules" );
+ $this->addWarning( [ 'apierror-badmodule-nosubmodules', $path ], 'badmodule' );
}
} else {
$modules[] = $path;
foreach ( $modules as $m ) {
try {
$module = $this->getModuleFromPath( $m );
- } catch ( UsageException $ex ) {
- $this->setWarning( $ex->getMessage() );
+ } catch ( ApiUsageException $ex ) {
+ foreach ( $ex->getStatusValue()->getErrors() as $error ) {
+ $this->addWarning( $error );
+ }
continue;
}
$key = 'modules';
/**
* List all submodules of a module
* @param ApiBase $module
- * @param boolean $recursive
+ * @param bool $recursive
* @return string[]
*/
private function listAllSubmodules( ApiBase $module, $recursive ) {
}
/**
- * @param array $res Result array
+ * @param array &$res Result array
* @param string $key Result key
* @param Message[] $msgs
* @param bool $joinLists
/**
* @param ApiBase $module
- * @return ApiResult
+ * @return array
*/
private function getModuleInfo( $module ) {
$ret = [];
$item['multi'] = !empty( $settings[ApiBase::PARAM_ISMULTI] );
if ( $item['multi'] ) {
- $item['limit'] = $this->getMain()->canApiHighLimits() ?
- ApiBase::LIMIT_SML2 :
- ApiBase::LIMIT_SML1;
- $item['lowlimit'] = ApiBase::LIMIT_SML1;
- $item['highlimit'] = ApiBase::LIMIT_SML2;
+ $item['lowlimit'] = !empty( $settings[ApiBase::PARAM_ISMULTI_LIMIT1] )
+ ? $settings[ApiBase::PARAM_ISMULTI_LIMIT1]
+ : ApiBase::LIMIT_SML1;
+ $item['highlimit'] = !empty( $settings[ApiBase::PARAM_ISMULTI_LIMIT2] )
+ ? $settings[ApiBase::PARAM_ISMULTI_LIMIT2]
+ : ApiBase::LIMIT_SML2;
+ $item['limit'] = $this->getMain()->canApiHighLimits()
+ ? $item['highlimit']
+ : $item['lowlimit'];
}
if ( !empty( $settings[ApiBase::PARAM_ALLOW_DUPLICATES] ) ) {
if ( isset( $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX] ) ) {
$item['submoduleparamprefix'] = $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX];
}
+
+ $deprecatedSubmodules = [];
+ foreach ( $item['submodules'] as $v => $submodulePath ) {
+ try {
+ $submod = $this->getModuleFromPath( $submodulePath );
+ if ( $submod && $submod->isDeprecated() ) {
+ $deprecatedSubmodules[] = $v;
+ }
+ } catch ( ApiUsageException $ex ) {
+ // Ignore
+ }
+ }
+ if ( $deprecatedSubmodules ) {
+ $item['type'] = array_merge(
+ array_diff( $item['type'], $deprecatedSubmodules ),
+ $deprecatedSubmodules
+ );
+ $item['deprecatedvalues'] = $deprecatedSubmodules;
+ }
} elseif ( $settings[ApiBase::PARAM_TYPE] === 'tags' ) {
$item['type'] = ChangeTags::listExplicitlyDefinedTags();
} else {
( is_array( $item['type'] ) || $item['type'] === 'namespace' ) ) {
$item['allspecifier'] = $allSpecifier;
}
+
+ if ( $item['type'] === 'namespace' &&
+ isset( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] ) &&
+ is_array( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] )
+ ) {
+ $item['extranamespaces'] = $settings[ApiBase::PARAM_EXTRA_NAMESPACES];
+ ApiResult::setArrayType( $item['extranamespaces'], 'array' );
+ ApiResult::setIndexedTagName( $item['extranamespaces'], 'ns' );
+ }
}
if ( isset( $settings[ApiBase::PARAM_MAX] ) ) {
$item['max'] = $settings[ApiBase::PARAM_MAX];
if ( !empty( $settings[ApiBase::PARAM_RANGE_ENFORCE] ) ) {
$item['enforcerange'] = true;
}
+ if ( !empty( $settings[ApiBase::PARAM_DEPRECATED_VALUES] ) ) {
+ $deprecatedValues = array_keys( $settings[ApiBase::PARAM_DEPRECATED_VALUES] );
+ if ( is_array( $item['type'] ) ) {
+ $deprecatedValues = array_intersect( $deprecatedValues, $item['type'] );
+ }
+ if ( $deprecatedValues ) {
+ $item['deprecatedvalues'] = array_values( $deprecatedValues );
+ ApiResult::setIndexedTagName( $item['deprecatedvalues'], 'v' );
+ }
+ }
if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) {
$item['info'] = [];
}
public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Parameter_information';
+ return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parameter_information';
}
}