Index: branches/REL1_15/phase3/includes/api/ApiQueryBacklinks.php |
— | — | @@ -185,7 +185,7 @@ |
186 | 186 | $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2/2 : ApiBase::LIMIT_BIG2 ); |
187 | 187 | if( $this->params['limit'] == 'max' ) { |
188 | 188 | $this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
189 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $this->params['limit'] ); |
| 189 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $this->params['limit'] ); |
190 | 190 | } |
191 | 191 | |
192 | 192 | $this->processContinue(); |
Index: branches/REL1_15/phase3/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/REL1_15/phase3/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 | | - if ($arr === null || $name === null || $value === null || !is_array($arr) || is_array($name)) |
146 | | - ApiBase :: dieDebug(__METHOD__, 'Bad parameter'); |
147 | | - |
148 | | - if (!isset ($arr[$name])) { |
| 145 | + public static function setElement( &$arr, $name, $value, $overwrite = false ) { |
| 146 | + if ( $arr === null || $name === null || $value === null || !is_array( $arr ) || is_array( $name ) ) { |
| 147 | + ApiBase::dieDebug( __METHOD__, 'Bad parameter' ); |
| 148 | + } |
| 149 | + if ( !isset ( $arr[$name] ) || $overwrite ) { |
149 | 150 | $arr[$name] = $value; |
150 | 151 | } |
151 | 152 | elseif (is_array($arr[$name]) && is_array($value)) { |
— | — | @@ -239,7 +240,7 @@ |
240 | 241 | * If $name is empty, the $value is added as a next list element data[] = $value |
241 | 242 | * @return bool True if $value fits in the result, false if not |
242 | 243 | */ |
243 | | - public function addValue($path, $name, $value) { |
| 244 | + public function addValue( $path, $name, $value, $overwrite = false ) { |
244 | 245 | global $wgAPIMaxResultSize; |
245 | 246 | $data = & $this->mData; |
246 | 247 | if( $this->mCheckingSize ) { |
— | — | @@ -262,13 +263,24 @@ |
263 | 264 | $data = & $data[$path]; |
264 | 265 | } |
265 | 266 | } |
266 | | - |
267 | | - if (!$name) |
268 | | - $data[] = $value; // Add list element |
269 | | - else |
270 | | - ApiResult :: setElement($data, $name, $value); // Add named element |
| 267 | + if ( !$name ) { |
| 268 | + $data[] = $value; // Add list element |
| 269 | + } else { |
| 270 | + self::setElement( $data, $name, $value, $overwrite ); // Add named element |
| 271 | + } |
271 | 272 | return true; |
272 | 273 | } |
| 274 | + |
| 275 | + /** |
| 276 | + * Add a parsed limit=max to the result. |
| 277 | + * |
| 278 | + * @param $moduleName string |
| 279 | + * @param $limit int |
| 280 | + */ |
| 281 | + public function setParsedLimit( $moduleName, $limit ) { |
| 282 | + // Add value, allowing overwriting |
| 283 | + $this->addValue( 'limits', $moduleName, $limit, true ); |
| 284 | + } |
273 | 285 | |
274 | 286 | /** |
275 | 287 | * Unset a value previously added to the result set. |
Index: branches/REL1_15/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -172,7 +172,7 @@ |
173 | 173 | $limit = $params['limit']; |
174 | 174 | if( $limit == 'max' ) { |
175 | 175 | $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
176 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit ); |
| 176 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $limit ); |
177 | 177 | } |
178 | 178 | |
179 | 179 | if ($enumRevMode) { |
Index: branches/REL1_15/phase3/includes/api/ApiBase.php |
— | — | @@ -548,21 +548,16 @@ |
549 | 549 | } |
550 | 550 | break; |
551 | 551 | case 'limit' : |
552 | | - if (!isset ($paramSettings[self :: PARAM_MAX]) || !isset ($paramSettings[self :: PARAM_MAX2])) |
553 | | - ApiBase :: dieDebug(__METHOD__, "MAX1 or MAX2 are not defined for the limit $encParamName"); |
554 | | - if ($multi) |
555 | | - ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $encParamName"); |
556 | | - $min = isset ($paramSettings[self :: PARAM_MIN]) ? $paramSettings[self :: PARAM_MIN] : 0; |
557 | | - if( $value == 'max' ) { |
558 | | - if( $parseMaxLimit ) { |
559 | | - $value = $this->getMain()->canApiHighLimits() ? $paramSettings[self :: PARAM_MAX2] : $paramSettings[self :: PARAM_MAX]; |
560 | | - $this->getResult()->addValue( 'limits', $this->getModuleName(), $value ); |
561 | | - $this->validateLimit($paramName, $value, $min, $paramSettings[self :: PARAM_MAX], $paramSettings[self :: PARAM_MAX2]); |
562 | | - } |
| 552 | + if ( $multi ) { |
| 553 | + ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" ); |
563 | 554 | } |
564 | | - else { |
565 | | - $value = intval($value); |
566 | | - $this->validateLimit($paramName, $value, $min, $paramSettings[self :: PARAM_MAX], $paramSettings[self :: PARAM_MAX2]); |
| 555 | + $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0; |
| 556 | + if ( $value == 'max' ) { |
| 557 | + $value = $this->getMain()->canApiHighLimits() ? $paramSettings[self::PARAM_MAX2] : $paramSettings[self::PARAM_MAX]; |
| 558 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $value ); |
| 559 | + } else { |
| 560 | + $value = intval( $value ); |
| 561 | + $this->validateLimit( $paramName, $value, $min, $paramSettings[self::PARAM_MAX], $paramSettings[self::PARAM_MAX2] ); |
567 | 562 | } |
568 | 563 | break; |
569 | 564 | case 'boolean' : |
Property changes on: branches/REL1_15/phase3/includes/api |
___________________________________________________________________ |
Modified: svn:mergeinfo |
570 | 565 | Merged /trunk/phase3/includes/api:r70078 |
Property changes on: branches/REL1_15/phase3/includes |
___________________________________________________________________ |
Modified: svn:mergeinfo |
571 | 566 | Merged /trunk/phase3/includes:r70078 |
Index: branches/REL1_15/phase3/RELEASE-NOTES |
— | — | @@ -3,6 +3,12 @@ |
4 | 4 | Security reminder: MediaWiki does not require PHP's register_globals |
5 | 5 | setting since version 1.2.0. If you have it on, turn it *off* if you can. |
6 | 6 | |
| 7 | +== Changes since 1.15.4 == |
| 8 | +* (bug 24564) Fix fatal errors when using list=deletedrevs, prop=revisions or |
| 9 | + one of the backlinks generators with limit=max. |
| 10 | +* (bug 24740) limit=max still causing problems on 1.15.5 (backport r70078, |
| 11 | + bug 24564) |
| 12 | + |
7 | 13 | == MediaWiki 1.15.5 == |
8 | 14 | |
9 | 15 | 2010-07-28 |
Property changes on: branches/REL1_15/phase3 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
10 | 16 | Merged /trunk/phase3:r70078 |