http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70189
Revision: 70189
Author: tstarling
Date: 2010-07-30 05:38:51 +0000 (Fri, 30 Jul 2010)
Log Message:
-----------
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/ApiBase.php
branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php
branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php
branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php
branches/wmf/1.16wmf4/includes/api/ApiResult.php
Property Changed:
----------------
branches/wmf/1.16wmf4/includes/api/
branches/wmf/1.16wmf4/includes/api/ApiBase.php
branches/wmf/1.16wmf4/includes/api/ApiLogin.php
branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php
Property changes on: branches/wmf/1.16wmf4/includes/api
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/api:51646
/branches/REL1_16/phase3/includes/api:69932
/branches/sqlite/includes/api:58211-58321
/branches/wmf-deployment/includes/api:53381,59952,60970
/trunk/phase3/includes/api:63549,63764,63897-63901,64454,66486,69339,69347,69350,69369,69379,69776,69931
+ /branches/REL1_15/phase3/includes/api:51646
/branches/REL1_16/phase3/includes/api:69932
/branches/sqlite/includes/api:58211-58321
/branches/wmf-deployment/includes/api:53381,59952,60970
/trunk/phase3/includes/api:63549,63764,63897-63901,64454,66486,69339,69347,69350,69369,69379,69776,69931,70078
Modified: branches/wmf/1.16wmf4/includes/api/ApiBase.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiBase.php 2010-07-30 02:12:38 UTC
(rev 70188)
+++ branches/wmf/1.16wmf4/includes/api/ApiBase.php 2010-07-30 05:38:51 UTC
(rev 70189)
@@ -631,7 +631,7 @@
$min = isset(
$paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0;
if ( $value == 'max' ) {
$value =
$this->getMain()->canApiHighLimits() ? $paramSettings[self::PARAM_MAX2] :
$paramSettings[self::PARAM_MAX];
-
$this->getResult()->addValue( 'limits', $this->getModuleName(), $value );
+
$this->getResult()->setParsedLimit( $this->getModuleName(), $value );
} else {
$value = intval( $value
);
$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
- /branches/REL1_15/phase3/includes/api/ApiBase.php:51646
/branches/sqlite/includes/api/ApiBase.php:58211-58321
/branches/wmf-deployment/includes/api/ApiBase.php:53381,59952,60970
/trunk/phase3/includes/api/ApiBase.php:63549,63764,63897-63901,64454,66486,70062
+ /branches/REL1_15/phase3/includes/api/ApiBase.php:51646
/branches/sqlite/includes/api/ApiBase.php:58211-58321
/branches/wmf-deployment/includes/api/ApiBase.php:53381,59952,60970
/trunk/phase3/includes/api/ApiBase.php:63549,63764,63897-63901,64454,66486,70062,70078
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiLogin.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/api/ApiLogin.php:51646
/branches/REL1_16/phase3/includes/api/ApiLogin.php:69932
/branches/sqlite/includes/api/ApiLogin.php:58211-58321
/branches/wmf-deployment/includes/api/ApiLogin.php:53381,59952,60970
/trunk/phase3/includes/api/ApiLogin.php:63549,63764,63897-63901,64454,64694,66486
+ /branches/REL1_15/phase3/includes/api/ApiLogin.php:51646
/branches/REL1_16/phase3/includes/api/ApiLogin.php:69932
/branches/sqlite/includes/api/ApiLogin.php:58211-58321
/branches/wmf-deployment/includes/api/ApiLogin.php:53381,59952,60970
/trunk/phase3/includes/api/ApiLogin.php:63549,63764,63897-63901,64454,64694,66486,70078
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php
___________________________________________________________________
Modified: svn:mergeinfo
-
/trunk/phase3/includes/api/ApiQueryAllUsers.php:69339,69347,69350,69369,69379,69776,69931
+
/trunk/phase3/includes/api/ApiQueryAllUsers.php:69339,69347,69350,69369,69379,69776,69931,70078
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php 2010-07-30
02:12:38 UTC (rev 70188)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php 2010-07-30
05:38:51 UTC (rev 70189)
@@ -197,7 +197,7 @@
$botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 :
ApiBase::LIMIT_BIG2 );
if ( $this->params['limit'] == 'max' ) {
$this->params['limit'] =
$this->getMain()->canApiHighLimits() ? $botMax : $userMax;
- $this->getResult()->addValue( 'limits',
$this->getModuleName(), $this->params['limit'] );
+ $this->getResult()->setParsedLimit(
$this->getModuleName(), $this->params['limit'] );
}
$this->processContinue();
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php 2010-07-30
02:12:38 UTC (rev 70188)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php 2010-07-30
05:38:51 UTC (rev 70189)
@@ -106,7 +106,7 @@
if ( $limit == 'max' ) {
$limit = $this->getMain()->canApiHighLimits() ? $botMax
: $userMax;
- $this->getResult()->addValue( 'limits',
$this->getModuleName(), $limit );
+ $this->getResult()->setParsedLimit(
$this->getModuleName(), $limit );
}
$this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php 2010-07-30
02:12:38 UTC (rev 70188)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php 2010-07-30
05:38:51 UTC (rev 70189)
@@ -194,7 +194,7 @@
$limit = $params['limit'];
if ( $limit == 'max' ) {
$limit = $this->getMain()->canApiHighLimits() ? $botMax
: $userMax;
- $this->getResult()->addValue( 'limits',
$this->getModuleName(), $limit );
+ $this->getResult()->setParsedLimit(
$this->getModuleName(), $limit );
}
if ( $enumRevMode ) {
Modified: branches/wmf/1.16wmf4/includes/api/ApiResult.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiResult.php 2010-07-30 02:12:38 UTC
(rev 70188)
+++ branches/wmf/1.16wmf4/includes/api/ApiResult.php 2010-07-30 05:38:51 UTC
(rev 70189)
@@ -139,12 +139,13 @@
* @param $arr array to add $value to
* @param $name string Index of $arr to add $value at
* @param $value mixed
+ * @param $overwrite bool Whether overwriting an existing element is
allowed
*/
- public static function setElement( & $arr, $name, $value ) {
+ public static function setElement( & $arr, $name, $value, $overwrite =
false ) {
if ( $arr === null || $name === null || $value === null ||
!is_array( $arr ) || is_array( $name ) )
ApiBase :: dieDebug( __METHOD__, 'Bad parameter' );
- if ( !isset ( $arr[$name] ) ) {
+ if ( !isset ( $arr[$name] ) || $overwrite ) {
$arr[$name] = $value;
}
elseif ( is_array( $arr[$name] ) && is_array( $value ) ) {
@@ -238,7 +239,7 @@
* If $name is empty, the $value is added as a next list element data[]
= $value
* @return bool True if $value fits in the result, false if not
*/
- public function addValue( $path, $name, $value ) {
+ public function addValue( $path, $name, $value, $overwrite = false ) {
global $wgAPIMaxResultSize;
$data = & $this->mData;
if ( $this->mCheckingSize ) {
@@ -265,9 +266,20 @@
if ( !$name )
$data[] = $value; // Add list element
else
- ApiResult :: setElement( $data, $name, $value );
// Add named element
+ ApiResult :: setElement( $data, $name, $value,
$overwrite ); // Add named element
return true;
}
+
+ /**
+ * Add a parsed limit=max to the result.
+ *
+ * @param $moduleName string
+ * @param $limit int
+ */
+ public function setParsedLimit( $moduleName, $limit ) {
+ // Add value, allowing overwriting
+ $this->addValue( 'limits', $moduleName, $limit, true );
+ }
/**
* Unset a value previously added to the result set.
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs