From: Roan Kattouw Date: Tue, 5 Aug 2008 16:32:28 +0000 (+0000) Subject: API: X-Git-Tag: 1.31.0-rc.0~46114 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=5331e82bd5d9bd643225d2d9e3bafdcda979137d;p=lhc%2Fweb%2Fwiklou.git API: * (bug 15048) Added limit field for multivalue parameters to action=paraminfo output. * When the limit on multivalue parameters is exceeded, a warning is issued --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e9a5ee3b26..f76cdefdf0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -71,6 +71,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN are now listed on action=help * (bug 15044) Added requestid parameter to api.php to facilitate distinguishing between requests +* (bug 15048) Added limit field for multivalue parameters to action=paraminfo + output. +* When the limit on multivalue parameters is exceeded, a warning is issued === Languages updated in 1.14 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 4409bea46f..9f66869b00 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -515,10 +515,12 @@ abstract class ApiBase { protected function parseMultiValue($valueName, $value, $allowMultiple, $allowedValues) { if( trim($value) === "" ) return array(); - $sizeLimit = $this->mMainModule->canApiHighLimits() ? 501 : 51; - $valuesList = explode('|', $value,$sizeLimit); - if( count($valuesList) == $sizeLimit ) { + $sizeLimit = $this->mMainModule->canApiHighLimits() ? self::LIMIT_SML2 : self::LIMIT_SML1; + $valuesList = explode('|', $value, $sizeLimit + 1); + if( count($valuesList) == $sizeLimit + 1 ) { $junk = array_pop($valuesList); // kill last jumbled param + // Set a warning too + $this->setWarning("Too many values supplied for parameter '$valueName': the limit is $sizeLimit"); } if (!$allowMultiple && count($valuesList) != 1) { $possibleValues = is_array($allowedValues) ? "of '" . implode("', '", $allowedValues) . "'" : ''; diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 2e9da654e8..22f14a36d4 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -111,7 +111,7 @@ class ApiMain extends ApiBase { 'params' => array() ), 'apihighlimits' => array( - 'msg' => 'Use higher limits in API queries (Slow queries: $1 results; Fast queries: $2 results). These limits also apply to multivalue parameters.', + 'msg' => 'Use higher limits in API queries (Slow queries: $1 results; Fast queries: $2 results). The limits for slow queries also apply to multivalue parameters.', 'params' => array (ApiMain::LIMIT_SML2, ApiMain::LIMIT_BIG2) ) ); diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index d823eef027..91e526e76c 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -111,7 +111,12 @@ class ApiParamInfo extends ApiBase { $a['default'] = $p[ApiBase::PARAM_DFLT]; if(isset($p[ApiBase::PARAM_ISMULTI])) if($p[ApiBase::PARAM_ISMULTI]) + { $a['multi'] = ''; + $a['limit'] = $this->getMain()->canApiHighLimits() ? + ApiBase::LIMIT_SML2 : + ApiBase::LIMIT_SML1; + } if(isset($p[ApiBase::PARAM_TYPE])) { $a['type'] = $p[ApiBase::PARAM_TYPE];