API performance fixes: avoid unstubbing $wgContLang and $wgUser
authorRoan Kattouw <catrope@users.mediawiki.org>
Mon, 15 Feb 2010 20:50:21 +0000 (20:50 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Mon, 15 Feb 2010 20:50:21 +0000 (20:50 +0000)
api.php
includes/api/ApiBase.php

diff --git a/api.php b/api.php
index 852a808..10baa13 100644 (file)
--- 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,
index ff54af1..a3033fb 100644 (file)
@@ -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" );