From: Tim Starling Date: Wed, 28 Jul 2010 04:12:36 +0000 (+0000) Subject: Reintroduced the extractRequestParams() memoization as in r69782, but respecting... X-Git-Tag: 1.31.0-rc.0~35871 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=6afbc6762cf5bdb34630feaaeb0332055f48b330;p=lhc%2Fweb%2Fwiklou.git Reintroduced the extractRequestParams() memoization as in r69782, but respecting $parseLimit. Fixes bug 24564 (fatal error due to duplicate calls to addValue()). --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index d4f7d95661..698b2cdfcf 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -57,6 +57,7 @@ abstract class ApiBase { const LIMIT_SML2 = 500; // Slow query, bot/sysop limit private $mMainModule, $mModuleName, $mModulePrefix; + private $mParamCache = array(); /** * Constructor @@ -479,16 +480,20 @@ abstract class ApiBase { * @return array */ public function extractRequestParams( $parseLimit = true ) { - $params = $this->getFinalParams(); - $results = array(); - - if ( $params ) { // getFinalParams() can return false - foreach ( $params as $paramName => $paramSettings ) { - $results[$paramName] = $this->getParameterFromSettings( $paramName, $paramSettings, $parseLimit ); + // Cache parameters, for performance and to avoid bug 24564. + if ( !isset( $this->mParamCache[$parseLimit] ) ) { + $params = $this->getFinalParams(); + $results = array(); + + if ( $params ) { // getFinalParams() can return false + foreach ( $params as $paramName => $paramSettings ) { + $results[$paramName] = $this->getParameterFromSettings( + $paramName, $paramSettings, $parseLimit ); + } } + $this->mParamCache[$parseLimit] = $results; } - - return $results; + return $this->mParamCache[$parseLimit]; } /**