* Add limit=max to API. It also adds limit info to output
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Thu, 29 Nov 2007 15:19:56 +0000 (15:19 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Thu, 29 Nov 2007 15:19:56 +0000 (15:19 +0000)
RELEASE-NOTES
includes/api/ApiBase.php

index 0ec26cf..4c38b60 100644 (file)
@@ -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 ===
 
index 2191a95..843a3fa 100644 (file)
@@ -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);
                                }