From 6afbc6762cf5bdb34630feaaeb0332055f48b330 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 28 Jul 2010 04:12:36 +0000 Subject: [PATCH] Reintroduced the extractRequestParams() memoization as in r69782, but respecting $parseLimit. Fixes bug 24564 (fatal error due to duplicate calls to addValue()). --- includes/api/ApiBase.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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]; } /** -- 2.20.1