From 197ebe413ce22699abcd3d632bcd95eaa40de236 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Thu, 29 Nov 2007 15:19:56 +0000 Subject: [PATCH] * Add limit=max to API. It also adds limit info to output --- RELEASE-NOTES | 1 + includes/api/ApiBase.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0ec26cf8d7..4c38b60c7f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -303,6 +303,7 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API * Added support for traditional, unified and array diffs to prop=revisions * Make prop=info check for restrictions in the old format too. * Add apihighlimits permission, default for sysops and bots +* Add limit=max to use maximal limit === Languages updated in 1.12 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 2191a95293..843a3fa967 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -410,7 +410,13 @@ abstract class ApiBase { if ($multi) ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $encParamName"); $min = isset ($paramSettings[self :: PARAM_MIN]) ? $paramSettings[self :: PARAM_MIN] : 0; - $value = intval($value); + if( $value == 'max' ) { + $value = $this->getMain()->canApiHighLimits() ? $paramSettings[self :: PARAM_MAX2] : $paramSettings[self :: PARAM_MAX]; + $this->getResult()->addValue( 'limits', 'limit', $value ); + } + else { + $value = intval($value); + } $this->validateLimit($paramName, $value, $min, $paramSettings[self :: PARAM_MAX], $paramSettings[self :: PARAM_MAX2]); break; case 'boolean' : @@ -485,7 +491,7 @@ abstract class ApiBase { // Optimization: do not check user's bot status unless really needed -- skips db query // assumes $botMax >= $max if (!is_null($max) && $value > $max) { - if (!is_null($botMax) && ($this->getMain()->canApiHighLimits())) { + if (!is_null($botMax) && $this->getMain()->canApiHighLimits()) { if ($value > $botMax) { $this->dieUsage($this->encodeParamName($paramName) . " may not be over $botMax (set to $value) for bots or sysops", $paramName); } -- 2.20.1