From: Reedy Date: Wed, 5 Sep 2012 22:21:54 +0000 (+0100) Subject: * (bug 39665) Cache AllowedGenerator array so it doesn't autoload all query classes... X-Git-Tag: 1.31.0-rc.0~22455 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=0b53b320c43c8e0308967bc1152b6f6e7d444a55;p=lhc%2Fweb%2Fwiklou.git * (bug 39665) Cache AllowedGenerator array so it doesn't autoload all query classes on every request. Change-Id: I541ecf931a2bbe766bf31f569f81cc92308e35e1 --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index b5892f650e..6354e03b03 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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 === diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 7823e2f538..9c932a22c9 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -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 ); + } } /**