* (bug 39665) Cache AllowedGenerator array so it doesn't autoload all query classes...
authorReedy <reedy@wikimedia.org>
Wed, 5 Sep 2012 22:21:54 +0000 (23:21 +0100)
committerReedy <reedy@wikimedia.org>
Wed, 5 Sep 2012 22:34:23 +0000 (23:34 +0100)
Change-Id: I541ecf931a2bbe766bf31f569f81cc92308e35e1

RELEASE-NOTES-1.20
includes/api/ApiQuery.php

index b5892f6..6354e03 100644 (file)
@@ -273,6 +273,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * (bug 11142) Improve file extension blacklist error reporting in API upload.
 * (bug 39635) PostgreSQL LOCK IN SHARE MODE option is a syntax error.
 * (bug 36329) Accesskey tooltips for Firefox 14 on Mac should use "ctrl-option-" prefix.
+* (bug 39665) Cache AllowedGenerator array so it doesn't autoload all query classes
+  on every request.
 
 === Languages updated in 1.20 ===
 
index 7823e2f..9c932a2 100644 (file)
@@ -111,7 +111,8 @@ class ApiQuery extends ApiBase {
                parent::__construct( $main, $action );
 
                // Allow custom modules to be added in LocalSettings.php
-               global $wgAPIPropModules, $wgAPIListModules, $wgAPIMetaModules;
+               global $wgAPIPropModules, $wgAPIListModules, $wgAPIMetaModules,
+                       $wgMemc, $wgAPICacheHelpTimeout;
                self::appendUserModules( $this->mQueryPropModules, $wgAPIPropModules );
                self::appendUserModules( $this->mQueryListModules, $wgAPIListModules );
                self::appendUserModules( $this->mQueryMetaModules, $wgAPIMetaModules );
@@ -120,8 +121,22 @@ class ApiQuery extends ApiBase {
                $this->mListModuleNames = array_keys( $this->mQueryListModules );
                $this->mMetaModuleNames = array_keys( $this->mQueryMetaModules );
 
+               // Get array of query generators from cache if present
+               $key = wfMemcKey( 'apiquerygenerators', SpecialVersion::getVersion( 'nodb' ) );
+
+               if ( $wgAPICacheHelpTimeout > 0 ) {
+                       $cached = $wgMemc->get( $key );
+                       if ( $cached ) {
+                               $this->mAllowedGenerators = $cached;
+                               return;
+                       }
+               }
                $this->makeGeneratorList( $this->mQueryPropModules );
                $this->makeGeneratorList( $this->mQueryListModules );
+
+               if ( $wgAPICacheHelpTimeout > 0 ) {
+                       $wgMemc->set( $key, $this->mAllowedGenerators, $wgAPICacheHelpTimeout );
+               }
        }
 
        /**