Merge "[LanguageConverter] Added some cache code based on the problems in r97512."
authorCatrope <roan.kattouw@gmail.com>
Mon, 9 Apr 2012 22:25:23 +0000 (22:25 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 9 Apr 2012 22:25:24 +0000 (22:25 +0000)
includes/DefaultSettings.php
includes/GlobalFunctions.php
includes/Setup.php
languages/LanguageConverter.php
tests/phpunit/phpunit.php

index 48995a4..6788984 100644 (file)
@@ -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
@@ -4257,7 +4266,7 @@ $wgParserTestFiles = array(
  * );
  */
 $wgParserTestRemote = false;
+
 /**
  * Allow running of javascript test suites via [[Special:JavaScriptTest]] (such as QUnit).
  */
index 7237b53..8764783 100644 (file)
@@ -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
  *
index fd35a60..32cd75c 100644 (file)
@@ -448,6 +448,7 @@ wfProfileIn( $fname . '-memcached' );
 $wgMemc = wfGetMainCache();
 $messageMemc = wfGetMessageCacheStorage();
 $parserMemc = wfGetParserCacheStorage();
+$wgLangConvMemc = wfGetLangConverterCacheStorage();
 
 wfDebug( 'CACHES: ' . get_class( $wgMemc ) . '[main] ' .
        get_class( $messageMemc ) . '[message] ' .
index 2b9cc8e..00259e3 100644 (file)
@@ -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__ );
index 92eeffa..d18b33b 100755 (executable)
@@ -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' ) );
 }