(bug 31883) Limit of some params is not documented in API autodoc

Original bug description: Limit of bkusers of list=blocks and titles of
action=query is not documented in API help

For that params no PARAM_TYPE was set, determine the type with the same
code as in r85758 (action=paraminfo) and its modification in r86917

Move the adding of that text out of the else, than the doc is also
added to params with more than 50 default values
(which looks to be intend of that piece of code).

Change-Id: I3fa59d2a7ae688da79dab57dc0576a69f786cca5
This commit is contained in:
umherirrender 2012-04-01 19:50:15 +02:00 committed by Antoine Musso
parent 926afc65c3
commit 1788cc76c5
2 changed files with 24 additions and 16 deletions

View file

@ -64,6 +64,7 @@ production.
* (bug 34313) MediaWiki API intro message about "HTML format" should mention
the format parameter.
* (bug 32384) Allow descending order for list=watchlistraw
* (bug 31883) Limit of bkusers of list=blocks and titles of action=query is not documented in API help
=== Languages updated in 1.20 ===

View file

@ -367,21 +367,30 @@ abstract class ApiBase extends ContextSource {
$desc = implode( $paramPrefix, $desc );
}
//handle shorthand
if ( !is_array( $paramSettings ) ) {
$paramSettings = array(
self::PARAM_DFLT => $paramSettings,
);
}
$deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] ) ?
$paramSettings[self::PARAM_DEPRECATED] : false;
if ( $deprecated ) {
//handle missing type
if ( !isset( $paramSettings[ApiBase::PARAM_TYPE] ) ) {
$dflt = isset( $paramSettings[ApiBase::PARAM_DFLT] ) ? $paramSettings[ApiBase::PARAM_DFLT] : null;
if ( is_bool( $dflt ) ) {
$paramSettings[ApiBase::PARAM_TYPE] = 'boolean';
} elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
$paramSettings[ApiBase::PARAM_TYPE] = 'string';
} elseif ( is_int( $dflt ) ) {
$paramSettings[ApiBase::PARAM_TYPE] = 'integer';
}
}
if ( isset( $paramSettings[self::PARAM_DEPRECATED] ) && $paramSettings[self::PARAM_DEPRECATED] ) {
$desc = "DEPRECATED! $desc";
}
$required = isset( $paramSettings[self::PARAM_REQUIRED] ) ?
$paramSettings[self::PARAM_REQUIRED] : false;
if ( $required ) {
if ( isset( $paramSettings[self::PARAM_REQUIRED] ) && $paramSettings[self::PARAM_REQUIRED] ) {
$desc .= $paramPrefix . "This parameter is required";
}
@ -437,22 +446,20 @@ abstract class ApiBase extends ContextSource {
}
break;
}
}
if ( isset( $paramSettings[self::PARAM_ISMULTI] ) ) {
$isArray = is_array( $paramSettings[self::PARAM_TYPE] );
if ( isset( $paramSettings[self::PARAM_ISMULTI] ) && $paramSettings[self::PARAM_ISMULTI] ) {
$isArray = is_array( $type );
if ( !$isArray
|| $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1 ) {
$desc .= $paramPrefix . "Maximum number of values " .
self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
}
if ( !$isArray
|| $isArray && count( $type ) > self::LIMIT_SML1 ) {
$desc .= $paramPrefix . "Maximum number of values " .
self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
}
}
}
$default = is_array( $paramSettings )
? ( isset( $paramSettings[self::PARAM_DFLT] ) ? $paramSettings[self::PARAM_DFLT] : null )
: $paramSettings;
$default = isset( $paramSettings[self::PARAM_DFLT] ) ? $paramSettings[self::PARAM_DFLT] : null;
if ( !is_null( $default ) && $default !== false ) {
$desc .= $paramPrefix . "Default: $default";
}