Index: branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php |
— | — | @@ -197,7 +197,7 @@ |
198 | 198 | $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 : ApiBase::LIMIT_BIG2 ); |
199 | 199 | if ( $this->params['limit'] == 'max' ) { |
200 | 200 | $this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
201 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $this->params['limit'] ); |
| 201 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $this->params['limit'] ); |
202 | 202 | } |
203 | 203 | |
204 | 204 | $this->processContinue(); |
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | |
108 | 108 | if ( $limit == 'max' ) { |
109 | 109 | $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
110 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit ); |
| 110 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $limit ); |
111 | 111 | } |
112 | 112 | |
113 | 113 | $this->validateLimit( 'limit', $limit, 1, $userMax, $botMax ); |
Index: branches/wmf/1.16wmf4/includes/api/ApiResult.php |
— | — | @@ -139,12 +139,13 @@ |
140 | 140 | * @param $arr array to add $value to |
141 | 141 | * @param $name string Index of $arr to add $value at |
142 | 142 | * @param $value mixed |
| 143 | + * @param $overwrite bool Whether overwriting an existing element is allowed |
143 | 144 | */ |
144 | | - public static function setElement( & $arr, $name, $value ) { |
| 145 | + public static function setElement( & $arr, $name, $value, $overwrite = false ) { |
145 | 146 | if ( $arr === null || $name === null || $value === null || !is_array( $arr ) || is_array( $name ) ) |
146 | 147 | ApiBase :: dieDebug( __METHOD__, 'Bad parameter' ); |
147 | 148 | |
148 | | - if ( !isset ( $arr[$name] ) ) { |
| 149 | + if ( !isset ( $arr[$name] ) || $overwrite ) { |
149 | 150 | $arr[$name] = $value; |
150 | 151 | } |
151 | 152 | elseif ( is_array( $arr[$name] ) && is_array( $value ) ) { |
— | — | @@ -238,7 +239,7 @@ |
239 | 240 | * If $name is empty, the $value is added as a next list element data[] = $value |
240 | 241 | * @return bool True if $value fits in the result, false if not |
241 | 242 | */ |
242 | | - public function addValue( $path, $name, $value ) { |
| 243 | + public function addValue( $path, $name, $value, $overwrite = false ) { |
243 | 244 | global $wgAPIMaxResultSize; |
244 | 245 | $data = & $this->mData; |
245 | 246 | if ( $this->mCheckingSize ) { |
— | — | @@ -265,9 +266,20 @@ |
266 | 267 | if ( !$name ) |
267 | 268 | $data[] = $value; // Add list element |
268 | 269 | else |
269 | | - ApiResult :: setElement( $data, $name, $value ); // Add named element |
| 270 | + ApiResult :: setElement( $data, $name, $value, $overwrite ); // Add named element |
270 | 271 | return true; |
271 | 272 | } |
| 273 | + |
| 274 | + /** |
| 275 | + * Add a parsed limit=max to the result. |
| 276 | + * |
| 277 | + * @param $moduleName string |
| 278 | + * @param $limit int |
| 279 | + */ |
| 280 | + public function setParsedLimit( $moduleName, $limit ) { |
| 281 | + // Add value, allowing overwriting |
| 282 | + $this->addValue( 'limits', $moduleName, $limit, true ); |
| 283 | + } |
272 | 284 | |
273 | 285 | /** |
274 | 286 | * Unset a value previously added to the result set. |
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiLogin.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
275 | 287 | Merged /trunk/phase3/includes/api/ApiLogin.php:r70078 |
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php |
— | — | @@ -194,7 +194,7 @@ |
195 | 195 | $limit = $params['limit']; |
196 | 196 | if ( $limit == 'max' ) { |
197 | 197 | $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
198 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit ); |
| 198 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $limit ); |
199 | 199 | } |
200 | 200 | |
201 | 201 | if ( $enumRevMode ) { |
Index: branches/wmf/1.16wmf4/includes/api/ApiBase.php |
— | — | @@ -631,7 +631,7 @@ |
632 | 632 | $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0; |
633 | 633 | if ( $value == 'max' ) { |
634 | 634 | $value = $this->getMain()->canApiHighLimits() ? $paramSettings[self::PARAM_MAX2] : $paramSettings[self::PARAM_MAX]; |
635 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $value ); |
| 635 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $value ); |
636 | 636 | } else { |
637 | 637 | $value = intval( $value ); |
638 | 638 | $this->validateLimit( $paramName, $value, $min, $paramSettings[self::PARAM_MAX], $paramSettings[self::PARAM_MAX2] ); |
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiBase.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
639 | 639 | Merged /trunk/phase3/includes/api/ApiBase.php:r70078 |
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
640 | 640 | Merged /trunk/phase3/includes/api/ApiQueryAllUsers.php:r70078 |
Property changes on: branches/wmf/1.16wmf4/includes/api |
___________________________________________________________________ |
Modified: svn:mergeinfo |
641 | 641 | Merged /trunk/phase3/includes/api:r70078 |