r70189 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70188‎ | r70189 | r70190 >
Date:05:38, 30 July 2010
Author:tstarling
Status:ok
Tags:
Comment:
MFT r70078: Fix fatal errors when using list=deletedrevs, prop=revisions or one of the backlinks generators with limit=max.
Modified paths:
  • /branches/wmf/1.16wmf4/includes/api (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiBase.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiLogin.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiResult.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php
@@ -197,7 +197,7 @@
198198 $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 : ApiBase::LIMIT_BIG2 );
199199 if ( $this->params['limit'] == 'max' ) {
200200 $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'] );
202202 }
203203
204204 $this->processContinue();
Index: branches/wmf/1.16wmf4/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/wmf/1.16wmf4/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+ public static function setElement( & $arr, $name, $value, $overwrite = false ) {
145146 if ( $arr === null || $name === null || $value === null || !is_array( $arr ) || is_array( $name ) )
146147 ApiBase :: dieDebug( __METHOD__, 'Bad parameter' );
147148
148 - if ( !isset ( $arr[$name] ) ) {
 149+ if ( !isset ( $arr[$name] ) || $overwrite ) {
149150 $arr[$name] = $value;
150151 }
151152 elseif ( is_array( $arr[$name] ) && is_array( $value ) ) {
@@ -238,7 +239,7 @@
239240 * If $name is empty, the $value is added as a next list element data[] = $value
240241 * @return bool True if $value fits in the result, false if not
241242 */
242 - public function addValue( $path, $name, $value ) {
 243+ public function addValue( $path, $name, $value, $overwrite = false ) {
243244 global $wgAPIMaxResultSize;
244245 $data = & $this->mData;
245246 if ( $this->mCheckingSize ) {
@@ -265,9 +266,20 @@
266267 if ( !$name )
267268 $data[] = $value; // Add list element
268269 else
269 - ApiResult :: setElement( $data, $name, $value ); // Add named element
 270+ ApiResult :: setElement( $data, $name, $value, $overwrite ); // Add named element
270271 return true;
271272 }
 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+ }
272284
273285 /**
274286 * Unset a value previously added to the result set.
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiLogin.php
___________________________________________________________________
Modified: svn:mergeinfo
275287 Merged /trunk/phase3/includes/api/ApiLogin.php:r70078
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php
@@ -194,7 +194,7 @@
195195 $limit = $params['limit'];
196196 if ( $limit == 'max' ) {
197197 $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
198 - $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit );
 198+ $this->getResult()->setParsedLimit( $this->getModuleName(), $limit );
199199 }
200200
201201 if ( $enumRevMode ) {
Index: branches/wmf/1.16wmf4/includes/api/ApiBase.php
@@ -631,7 +631,7 @@
632632 $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0;
633633 if ( $value == 'max' ) {
634634 $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 );
636636 } else {
637637 $value = intval( $value );
638638 $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
639639 Merged /trunk/phase3/includes/api/ApiBase.php:r70078
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php
___________________________________________________________________
Modified: svn:mergeinfo
640640 Merged /trunk/phase3/includes/api/ApiQueryAllUsers.php:r70078
Property changes on: branches/wmf/1.16wmf4/includes/api
___________________________________________________________________
Modified: svn:mergeinfo
641641 Merged /trunk/phase3/includes/api:r70078

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70078(bug 24564) Fix fatal errors when using list=deletedrevs, prop=revisions or o...btongminh11:30, 28 July 2010

Status & tagging log