From 1788cc76c5ff072bc059f5f5e9faeb46486b6243 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 1 Apr 2012 19:50:15 +0200 Subject: [PATCH] (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 --- RELEASE-NOTES-1.20 | 1 + includes/api/ApiBase.php | 39 +++++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index c51722e5ab..40dbb32a12 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 607c47af92..5bff0cafb3 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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"; } -- 2.20.1