summaryrefslogtreecommitdiff
path: root/includes/LocalisationCache.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/LocalisationCache.php')
-rw-r--r--includes/LocalisationCache.php33
1 files changed, 31 insertions, 2 deletions
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__ );
}