From 9db190c7e736ec8d063187d4241b59feaf7dc2d1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 22 Jun 2011 11:28:20 +0200 Subject: update to MediaWiki 1.17.0 --- includes/LocalisationCache.php | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'includes/LocalisationCache.php') diff --git a/includes/LocalisationCache.php b/includes/LocalisationCache.php index 12925b68..9ead21f1 100644 --- a/includes/LocalisationCache.php +++ b/includes/LocalisationCache.php @@ -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__ ); } -- cgit v1.2.2