From: Aaron Schulz Date: Fri, 6 Apr 2012 19:45:49 +0000 (-0700) Subject: [LanguageConverter] Added some cache code based on the problems in r97512. X-Git-Tag: 1.31.0-rc.0~23955^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=10f49bd065fe138ff22d88d6e9e1e5e7ccdfddfb;p=lhc%2Fweb%2Fwiklou.git [LanguageConverter] Added some cache code based on the problems in r97512. * Added $wgLanguageConverterCacheType global to control LC cache type. We can use it to enable direct apc use for language converter (to match the live hack). * Added $wgLangConvMemc object, available via Setup.php Change 1: * Updated unit tests * Minor documentation cleanup in DefaultSettings.php Change-Id: Icd5dd28407e9759ce294c784ec41d9ca15c89616 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 8402d698d3..2482c79939 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1555,12 +1555,21 @@ $wgMessageCacheType = CACHE_ANYTHING; */ $wgParserCacheType = CACHE_ANYTHING; +/** + * The cache type for storing language conversion tables, + * which are used when parsing certain text and interface messages. + * + * For available types see $wgMainCacheType. + */ +$wgLanguageConverterCacheType = CACHE_ANYTHING; + /** * Advanced object cache configuration. * * Use this to define the class names and constructor parameters which are used * for the various cache types. Custom cache types may be defined here and - * referenced from $wgMainCacheType, $wgMessageCacheType or $wgParserCacheType. + * referenced from $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, + * or $wgLanguageConverterCacheType. * * The format is an associative array where the key is a cache identifier, and * the value is an associative array of parameters. The "class" parameter is the @@ -4222,7 +4231,7 @@ $wgParserTestFiles = array( * ); */ $wgParserTestRemote = false; - + /** * Allow running of javascript test suites via [[Special:JavaScriptTest]] (such as QUnit). */ diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 99570a75d8..c67b2674ca 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3920,6 +3920,16 @@ function wfGetParserCacheStorage() { return ObjectCache::getInstance( $wgParserCacheType ); } +/** + * Get the cache object used by the language converter + * + * @return BagOStuff + */ +function wfGetLangConverterCacheStorage() { + global $wgLanguageConverterCacheType; + return ObjectCache::getInstance( $wgLanguageConverterCacheType ); +} + /** * Call hook functions defined in $wgHooks * diff --git a/includes/Setup.php b/includes/Setup.php index 2777f73296..e9af0744ca 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -49,7 +49,7 @@ if ( !empty($wgActionPaths) && !isset($wgActionPaths['view']) ) { if ( !empty($wgActionPaths) && !isset($wgActionPaths['view']) ) { # 'view' is assumed the default action path everywhere in the code - # but is rarely filled in $wgActionPaths + # but is rarely filled in $wgActionPaths $wgActionPaths['view'] = $wgArticlePath ; } @@ -439,6 +439,7 @@ wfProfileIn( $fname . '-memcached' ); $wgMemc = wfGetMainCache(); $messageMemc = wfGetMessageCacheStorage(); $parserMemc = wfGetParserCacheStorage(); +$wgLangConvMemc = wfGetLangConverterCacheStorage(); wfDebug( 'CACHES: ' . get_class( $wgMemc ) . '[main] ' . get_class( $messageMemc ) . '[message] ' . diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 2b9cc8e7b6..00259e3e00 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -810,16 +810,18 @@ class LanguageConverter { * @param $fromCache Boolean: load from memcached? Defaults to true. */ function loadTables( $fromCache = true ) { + global $wgLangConvMemc; + if ( $this->mTablesLoaded ) { return; } - global $wgMemc; + wfProfileIn( __METHOD__ ); $this->mTablesLoaded = true; $this->mTables = false; if ( $fromCache ) { wfProfileIn( __METHOD__ . '-cache' ); - $this->mTables = $wgMemc->get( $this->mCacheKey ); + $this->mTables = $wgLangConvMemc->get( $this->mCacheKey ); wfProfileOut( __METHOD__ . '-cache' ); } if ( !$this->mTables @@ -837,7 +839,7 @@ class LanguageConverter { $this->postLoadTables(); $this->mTables[self::CACHE_VERSION_KEY] = true; - $wgMemc->set( $this->mCacheKey, $this->mTables, 43200 ); + $wgLangConvMemc->set( $this->mCacheKey, $this->mTables, 43200 ); wfProfileOut( __METHOD__ . '-recache' ); } wfProfileOut( __METHOD__ ); diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php index 92eeffa257..d18b33b8ec 100755 --- a/tests/phpunit/phpunit.php +++ b/tests/phpunit/phpunit.php @@ -21,12 +21,14 @@ class PHPUnitMaintClass extends Maintenance { public function finalSetup() { parent::finalSetup(); - global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgUseDatabaseMessages; + global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType; + global $wgLanguageConverterCacheType, $wgUseDatabaseMessages; global $wgLocaltimezone, $wgLocalisationCacheConf; $wgMainCacheType = CACHE_NONE; $wgMessageCacheType = CACHE_NONE; $wgParserCacheType = CACHE_NONE; + $wgLanguageConverterCacheType = CACHE_NONE; $wgUseDatabaseMessages = false; # Set for future resets @@ -46,7 +48,7 @@ require( RUN_MAINTENANCE_IF_MAIN ); if( !in_array( '--configuration', $_SERVER['argv'] ) ) { //Hack to eliminate the need to use the Makefile (which sucks ATM) - array_splice( $_SERVER['argv'], 1, 0, + array_splice( $_SERVER['argv'], 1, 0, array( '--configuration', $IP . '/tests/phpunit/suite.xml' ) ); }