]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/LocalisationCache.php
MediaWiki 1.17.0
[autoinstallsdev/mediawiki.git] / includes / LocalisationCache.php
index 12925b68cd43e2d21f3630a8d238800e3ee936e7..9ead21f1f4dd7527b0b102d863d4d503ca5a7ade 100644 (file)
@@ -101,7 +101,7 @@ class LocalisationCache {
         * by a fallback sequence.
         */
        static public $mergeableMapKeys = array( 'messages', 'namespaceNames', 'mathNames',
-               'dateFormats', 'defaultUserOptionOverrides', 'magicWords', 'imageFiles',
+               'dateFormats', 'defaultUserOptionOverrides', 'imageFiles',
                'preloadedMessages',
        );
 
@@ -122,6 +122,11 @@ class LocalisationCache {
         * key is removed after the first merge.
         */
        static public $optionalMergeKeys = array( 'bookstoreList' );
+       
+       /**
+        * Keys for items that are formatted like $magicWords
+        */
+       static public $magicWordKeys = array( 'magicWords' );
 
        /**
         * Keys for items where the subitems are stored in the backend separately.
@@ -187,7 +192,8 @@ class LocalisationCache {
                                self::$mergeableMapKeys,
                                self::$mergeableListKeys,
                                self::$mergeableAliasListKeys,
-                               self::$optionalMergeKeys
+                               self::$optionalMergeKeys,
+                               self::$magicWordKeys
                        ) );
                }
                return isset( $this->mergeableKeys[$key] );
@@ -435,6 +441,8 @@ class LocalisationCache {
                                        if ( isset( $value['inherit'] ) ) {
                                                unset( $value['inherit'] );
                                        }
+                               } elseif ( in_array( $key, self::$magicWordKeys ) ) {
+                                       $this->mergeMagicWords( $value, $fallbackValue );
                                }
                        }
                } else {
@@ -442,6 +450,20 @@ class LocalisationCache {
                }
        }
 
+       protected function mergeMagicWords( &$value, $fallbackValue ) {
+               foreach ( $fallbackValue as $magicName => $fallbackInfo ) {
+                       if ( !isset( $value[$magicName] ) ) {
+                               $value[$magicName] = $fallbackInfo;
+                       } else {
+                               $oldSynonyms = array_slice( $fallbackInfo, 1 );
+                               $newSynonyms = array_slice( $value[$magicName], 1 );
+                               $synonyms = array_values( array_unique( array_merge( 
+                                       $newSynonyms, $oldSynonyms ) ) );
+                               $value[$magicName] = array_merge( array( $fallbackInfo[0] ), $synonyms );
+                       }
+               }
+       }
+
        /**
         * Given an array mapping language code to localisation value, such as is
         * found in extension *.i18n.php files, iterate through a fallback sequence
@@ -621,6 +643,13 @@ class LocalisationCache {
                        }
                }
                $this->store->finishWrite();
+               
+               # Clear out the MessageBlobStore
+               # HACK: If using a null (i.e. disabled) storage backend, we
+               # can't write to the MessageBlobStore either
+               if ( !$this->store instanceof LCStore_Null ) {
+                       MessageBlobStore::clear();
+               }
 
                wfProfileOut( __METHOD__ );
        }