From: Roan Kattouw Date: Mon, 15 Feb 2010 20:50:21 +0000 (+0000) Subject: API performance fixes: avoid unstubbing $wgContLang and $wgUser X-Git-Tag: 1.31.0-rc.0~37740 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=3a953c8e302a034eeddba6e6a30b47d14d38d055;p=lhc%2Fweb%2Fwiklou.git API performance fixes: avoid unstubbing $wgContLang and $wgUser --- diff --git a/api.php b/api.php index 852a80816d..10baa13eb6 100644 --- a/api.php +++ b/api.php @@ -104,7 +104,7 @@ define( 'MW_API', true ); // Set a dummy $wgTitle, because $wgTitle == null breaks various things // In a perfect world this wouldn't be necessary -$wgTitle = Title::newFromText( 'API' ); +$wgTitle = Title::makeTitle( NS_MAIN, 'API' ); /* Construct an ApiMain with the arguments passed via the URL. What we get back * is some form of an ApiMain, possibly even one that produces an error message, diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index ff54af1003..a3033fb684 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -655,8 +655,11 @@ abstract class ApiBase { protected function parseMultiValue( $valueName, $value, $allowMultiple, $allowedValues ) { if ( trim( $value ) === "" && $allowMultiple ) return array(); - $sizeLimit = $this->mMainModule->canApiHighLimits() ? self::LIMIT_SML2 : self::LIMIT_SML1; - $valuesList = explode( '|', $value, $sizeLimit + 1 ); + + // This is a bit awkward, but we want to avoid calling canApiHighLimits() because it unstubs $wgUser + $valuesList = explode( '|', $value, self::LIMIT_SML2 + 1 ); + $sizeLimit = count( $valuesList ) > self::LIMIT_SML1 && $this->mMainModule->canApiHighLimits() ? + self::LIMIT_SML2 : self::LIMIT_SML1; if ( self::truncateArray( $valuesList, $sizeLimit ) ) { $this->setWarning( "Too many values supplied for parameter '$valueName': the limit is $sizeLimit" );