Index: trunk/phase3/includes/api/ApiQueryBacklinks.php |
— | — | @@ -203,7 +203,7 @@ |
204 | 204 | $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 : ApiBase::LIMIT_BIG2 ); |
205 | 205 | if ( $this->params['limit'] == 'max' ) { |
206 | 206 | $this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
207 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $this->params['limit'] ); |
| 207 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $this->params['limit'] ); |
208 | 208 | } |
209 | 209 | |
210 | 210 | $this->processContinue(); |
Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | |
115 | 115 | if ( $limit == 'max' ) { |
116 | 116 | $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
117 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit ); |
| 117 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $limit ); |
118 | 118 | } |
119 | 119 | |
120 | 120 | $this->validateLimit( 'limit', $limit, 1, $userMax, $botMax ); |
Index: trunk/phase3/includes/api/ApiResult.php |
— | — | @@ -141,13 +141,14 @@ |
142 | 142 | * @param $arr array to add $value to |
143 | 143 | * @param $name string Index of $arr to add $value at |
144 | 144 | * @param $value mixed |
| 145 | + * @param $overwrite bool Whether overwriting an existing element is allowed |
145 | 146 | */ |
146 | | - public static function setElement( &$arr, $name, $value ) { |
| 147 | + public static function setElement( &$arr, $name, $value, $overwrite = false ) { |
147 | 148 | if ( $arr === null || $name === null || $value === null || !is_array( $arr ) || is_array( $name ) ) { |
148 | 149 | ApiBase::dieDebug( __METHOD__, 'Bad parameter' ); |
149 | 150 | } |
150 | 151 | |
151 | | - if ( !isset ( $arr[$name] ) ) { |
| 152 | + if ( !isset ( $arr[$name] ) || $overwrite ) { |
152 | 153 | $arr[$name] = $value; |
153 | 154 | } elseif ( is_array( $arr[$name] ) && is_array( $value ) ) { |
154 | 155 | $merged = array_intersect_key( $arr[$name], $value ); |
— | — | @@ -250,7 +251,7 @@ |
251 | 252 | * If $name is empty, the $value is added as a next list element data[] = $value |
252 | 253 | * @return bool True if $value fits in the result, false if not |
253 | 254 | */ |
254 | | - public function addValue( $path, $name, $value ) { |
| 255 | + public function addValue( $path, $name, $value, $overwrite = false ) { |
255 | 256 | global $wgAPIMaxResultSize; |
256 | 257 | $data = &$this->mData; |
257 | 258 | if ( $this->mCheckingSize ) { |
— | — | @@ -280,10 +281,21 @@ |
281 | 282 | if ( !$name ) { |
282 | 283 | $data[] = $value; // Add list element |
283 | 284 | } else { |
284 | | - ApiResult::setElement( $data, $name, $value ); // Add named element |
| 285 | + self::setElement( $data, $name, $value, $overwrite ); // Add named element |
285 | 286 | } |
286 | 287 | return true; |
287 | 288 | } |
| 289 | + |
| 290 | + /** |
| 291 | + * Add a parsed limit=max to the result. |
| 292 | + * |
| 293 | + * @param $moduleName string |
| 294 | + * @param $limit int |
| 295 | + */ |
| 296 | + public function setParsedLimit( $moduleName, $limit ) { |
| 297 | + // Add value, allowing overwriting |
| 298 | + $this->addValue( 'limits', $moduleName, $limit, true ); |
| 299 | + } |
288 | 300 | |
289 | 301 | /** |
290 | 302 | * Unset a value previously added to the result set. |
Index: trunk/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -204,7 +204,7 @@ |
205 | 205 | $limit = $params['limit']; |
206 | 206 | if ( $limit == 'max' ) { |
207 | 207 | $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
208 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit ); |
| 208 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $limit ); |
209 | 209 | } |
210 | 210 | |
211 | 211 | if ( $enumRevMode ) { |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -682,7 +682,7 @@ |
683 | 683 | $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0; |
684 | 684 | if ( $value == 'max' ) { |
685 | 685 | $value = $this->getMain()->canApiHighLimits() ? $paramSettings[self::PARAM_MAX2] : $paramSettings[self::PARAM_MAX]; |
686 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $value ); |
| 686 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $value ); |
687 | 687 | } else { |
688 | 688 | $value = intval( $value ); |
689 | 689 | $this->validateLimit( $paramName, $value, $min, $paramSettings[self::PARAM_MAX], $paramSettings[self::PARAM_MAX2] ); |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -296,6 +296,8 @@ |
297 | 297 | * Fixed "link" parameter in image links with "thumb" parameter. |
298 | 298 | * (bug 23936) Add "displaytitle" to query/info API |
299 | 299 | * (bug 24485) Make iwbacklinks a generator, optionally display iwprefix and iwtitle |
| 300 | +* (bug 24564) Fix fatal errors when using list=deletedrevs, prop=revisions or |
| 301 | + one of the backlinks generators with limit=max. |
300 | 302 | |
301 | 303 | === Languages updated in 1.17 === |
302 | 304 | |