r70818 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70817‎ | r70818 | r70819 >
Date:14:21, 10 August 2010
Author:reedy
Status:ok
Tags:
Comment:
MFT r70078 to REL1_15

For bug 24740 limit=max still causing problems on 1.15.5 (backport r70078, bug 24564)
Modified paths:
  • /branches/REL1_15/phase3 (modified) (history)
  • /branches/REL1_15/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_15/phase3/includes (modified) (history)
  • /branches/REL1_15/phase3/includes/api (modified) (history)
  • /branches/REL1_15/phase3/includes/api/ApiBase.php (modified) (history)
  • /branches/REL1_15/phase3/includes/api/ApiQueryBacklinks.php (modified) (history)
  • /branches/REL1_15/phase3/includes/api/ApiQueryDeletedrevs.php (modified) (history)
  • /branches/REL1_15/phase3/includes/api/ApiQueryRevisions.php (modified) (history)
  • /branches/REL1_15/phase3/includes/api/ApiResult.php (modified) (history)

Diff [purge]

Index: branches/REL1_15/phase3/includes/api/ApiQueryBacklinks.php
@@ -185,7 +185,7 @@
186186 $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2/2 : ApiBase::LIMIT_BIG2 );
187187 if( $this->params['limit'] == 'max' ) {
188188 $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'] );
190190 }
191191
192192 $this->processContinue();
Index: branches/REL1_15/phase3/includes/api/ApiQueryDeletedrevs.php
@@ -106,7 +106,7 @@
107107
108108 if( $limit == 'max' ) {
109109 $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
110 - $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit );
 110+ $this->getResult()->setParsedLimit( $this->getModuleName(), $limit );
111111 }
112112
113113 $this->validateLimit('limit', $limit, 1, $userMax, $botMax);
Index: branches/REL1_15/phase3/includes/api/ApiResult.php
@@ -139,12 +139,13 @@
140140 * @param $arr array to add $value to
141141 * @param $name string Index of $arr to add $value at
142142 * @param $value mixed
 143+ * @param $overwrite bool Whether overwriting an existing element is allowed
143144 */
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 ) {
149150 $arr[$name] = $value;
150151 }
151152 elseif (is_array($arr[$name]) && is_array($value)) {
@@ -239,7 +240,7 @@
240241 * If $name is empty, the $value is added as a next list element data[] = $value
241242 * @return bool True if $value fits in the result, false if not
242243 */
243 - public function addValue($path, $name, $value) {
 244+ public function addValue( $path, $name, $value, $overwrite = false ) {
244245 global $wgAPIMaxResultSize;
245246 $data = & $this->mData;
246247 if( $this->mCheckingSize ) {
@@ -262,13 +263,24 @@
263264 $data = & $data[$path];
264265 }
265266 }
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+ }
271272 return true;
272273 }
 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+ }
273285
274286 /**
275287 * Unset a value previously added to the result set.
Index: branches/REL1_15/phase3/includes/api/ApiQueryRevisions.php
@@ -172,7 +172,7 @@
173173 $limit = $params['limit'];
174174 if( $limit == 'max' ) {
175175 $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
176 - $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit );
 176+ $this->getResult()->setParsedLimit( $this->getModuleName(), $limit );
177177 }
178178
179179 if ($enumRevMode) {
Index: branches/REL1_15/phase3/includes/api/ApiBase.php
@@ -548,21 +548,16 @@
549549 }
550550 break;
551551 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" );
563554 }
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] );
567562 }
568563 break;
569564 case 'boolean' :
Property changes on: branches/REL1_15/phase3/includes/api
___________________________________________________________________
Modified: svn:mergeinfo
570565 Merged /trunk/phase3/includes/api:r70078
Property changes on: branches/REL1_15/phase3/includes
___________________________________________________________________
Modified: svn:mergeinfo
571566 Merged /trunk/phase3/includes:r70078
Index: branches/REL1_15/phase3/RELEASE-NOTES
@@ -3,6 +3,12 @@
44 Security reminder: MediaWiki does not require PHP's register_globals
55 setting since version 1.2.0. If you have it on, turn it *off* if you can.
66
 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+
713 == MediaWiki 1.15.5 ==
814
915 2010-07-28
Property changes on: branches/REL1_15/phase3
___________________________________________________________________
Modified: svn:mergeinfo
1016 Merged /trunk/phase3:r70078

Follow-up revisions

RevisionCommit summaryAuthorDate
r70821Followup r70818...reedy14:25, 10 August 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70062Reintroduced the extractRequestParams() memoization as in r69782, but respect...tstarling04:12, 28 July 2010
r70066* MFT r70062: fix for bug 24564 (fatal error with limit=max)...tstarling05:52, 28 July 2010
r70078(bug 24564) Fix fatal errors when using list=deletedrevs, prop=revisions or o...btongminh11:30, 28 July 2010

Status & tagging log