Fix doxygen docs before REL1_19 branching
[lhc/web/wiklou.git] / includes / LocalisationCache.php
index f76ae11..3b1f45c 100644 (file)
@@ -159,6 +159,9 @@ class LocalisationCache {
                                case 'db':
                                        $storeClass = 'LCStore_DB';
                                        break;
+                               case 'accel':
+                                       $storeClass = 'LCStore_Accel';
+                                       break;
                                case 'detect':
                                        $storeClass = $wgCacheDirectory ? 'LCStore_CDB' : 'LCStore_DB';
                                        break;
@@ -188,14 +191,14 @@ class LocalisationCache {
         * @return bool
         */
        public function isMergeableKey( $key ) {
-               if ( !isset( $this->mergeableKeys ) ) {
+               if ( $this->mergeableKeys === null ) {
                        $this->mergeableKeys = array_flip( array_merge(
-                                       self::$mergeableMapKeys,
-                                       self::$mergeableListKeys,
-                                       self::$mergeableAliasListKeys,
-                                       self::$optionalMergeKeys,
-                                       self::$magicWordKeys
-                               ) );
+                               self::$mergeableMapKeys,
+                               self::$mergeableListKeys,
+                               self::$mergeableAliasListKeys,
+                               self::$optionalMergeKeys,
+                               self::$magicWordKeys
+                       ) );
                }
                return isset( $this->mergeableKeys[$key] );
        }
@@ -207,7 +210,7 @@ class LocalisationCache {
         * need to fetch all of the subitems from the cache individually.
         * @param $code
         * @param $key
-        * @return string
+        * @return mixed
         */
        public function getItem( $code, $key ) {
                if ( !isset( $this->loadedItems[$code][$key] ) ) {
@@ -348,7 +351,10 @@ class LocalisationCache {
                }
 
                $deps = $this->store->get( $code, 'deps' );
-               if ( $deps === null ) {
+               $keys = $this->store->get( $code, 'list', 'messages' );
+               $preload = $this->store->get( $code, 'preload' );
+               // Different keys may expire separately, at least in LCStore_Accel
+               if ( $deps === null || $keys === null || $preload === null ) {
                        wfDebug( __METHOD__."($code): cache missing, need to make one\n" );
                        return true;
                }
@@ -505,7 +511,7 @@ class LocalisationCache {
                                $oldSynonyms = array_slice( $fallbackInfo, 1 );
                                $newSynonyms = array_slice( $value[$magicName], 1 );
                                $synonyms = array_values( array_unique( array_merge(
-                                                       $newSynonyms, $oldSynonyms ) ) );
+                                       $newSynonyms, $oldSynonyms ) ) );
                                $value[$magicName] = array_merge( array( $fallbackInfo[0] ), $synonyms );
                        }
                }
@@ -542,7 +548,7 @@ class LocalisationCache {
         * @param $code
         */
        public function recache( $code ) {
-               global $wgExtensionMessagesFiles, $wgExtensionAliasesFiles;
+               global $wgExtensionMessagesFiles;
                wfProfileIn( __METHOD__ );
 
                if ( !$code ) {
@@ -637,22 +643,6 @@ class LocalisationCache {
                        }
                }
 
-               # Load deprecated $wgExtensionAliasesFiles
-               foreach ( $wgExtensionAliasesFiles as $fileName ) {
-                       $data = $this->readPHPFile( $fileName, 'aliases' );
-
-                       if ( !isset( $data['aliases'] ) ) {
-                               continue;
-                       }
-
-                       $used = $this->mergeExtensionItem( $codeSequence, 'specialPageAliases',
-                               $allData['specialPageAliases'], $data['aliases'] );
-
-                       if ( $used ) {
-                               $deps[] = new FileDependency( $fileName );
-                       }
-               }
-
                # Merge core data into extension data
                foreach ( $coreData as $key => $item ) {
                        $this->mergeItem( $key, $allData[$key], $item );
@@ -660,7 +650,6 @@ class LocalisationCache {
 
                # Add cache dependencies for any referenced globals
                $deps['wgExtensionMessagesFiles'] = new GlobalDependency( 'wgExtensionMessagesFiles' );
-               $deps['wgExtensionAliasesFiles'] = new GlobalDependency( 'wgExtensionAliasesFiles' );
                $deps['version'] = new ConstantDependency( 'MW_LC_VERSION' );
 
                # Add dependencies to the cache entry
@@ -829,6 +818,55 @@ interface LCStore {
        function set( $key, $value );
 }
 
+/**
+ * LCStore implementation which uses PHP accelerator to store data.
+ * This will work if one of XCache, WinCache or APC cacher is configured.
+ * (See ObjectCache.php)
+ */
+class LCStore_Accel implements LCStore {
+       var $currentLang;
+       var $keys;
+
+       public function __construct() {
+               $this->cache = wfGetCache( CACHE_ACCEL );
+       }
+
+       public function get( $code, $key ) {
+               $k = wfMemcKey( 'l10n', $code, 'k', $key );
+               $r = $this->cache->get( $k );
+               return $r === false ? null : $r;
+       }
+
+       public function startWrite( $code ) {
+               $k = wfMemcKey( 'l10n', $code, 'l' );
+               $keys = $this->cache->get( $k );
+               if ( $keys ) {
+                       foreach ( $keys as $k ) {
+                               $this->cache->delete( $k );
+                       }
+               }
+               $this->currentLang = $code;
+               $this->keys = array();
+       }
+
+       public function finishWrite() {
+               if ( $this->currentLang ) {
+                       $k = wfMemcKey( 'l10n', $this->currentLang, 'l' );
+                       $this->cache->set( $k, array_keys( $this->keys ) );
+               }
+               $this->currentLang = null;
+               $this->keys = array();
+       }
+
+       public function set( $key, $value ) {
+               if ( $this->currentLang ) {
+                       $k = wfMemcKey( 'l10n', $this->currentLang, 'k', $key );
+                       $this->keys[$k] = true;
+                       $this->cache->set( $k, $value );
+               }
+       }
+}
+
 /**
  * LCStore implementation which uses the standard DB functions to store data.
  * This will work on any MediaWiki installation.
@@ -1077,7 +1115,7 @@ class LocalisationCache_BulkLoad extends LocalisationCache {
        /**
         * @param $code
         * @param $key
-        * @return string
+        * @return mixed
         */
        public function getItem( $code, $key ) {
                unset( $this->mruLangs[$code] );
@@ -1126,4 +1164,4 @@ class LocalisationCache_BulkLoad extends LocalisationCache {
                        $this->unload( $code );
                }
        }
-}
+}
\ No newline at end of file