Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.git] / includes / cache / localisation / LocalisationCache.php
index f20637a..bb84f97 100644 (file)
@@ -106,58 +106,59 @@ class LocalisationCache {
        /**
         * All item keys
         */
-       static public $allKeys = [
+       public static $allKeys = [
                'fallback', 'namespaceNames', 'bookstoreList',
-               'magicWords', 'messages', 'rtl', 'capitalizeAllNouns', 'digitTransformTable',
-               'separatorTransformTable', 'minimumGroupingDigits',
-               'fallback8bitEncoding', 'linkPrefixExtension',
-               'linkTrail', 'linkPrefixCharset', 'namespaceAliases',
-               'dateFormats', 'datePreferences', 'datePreferenceMigrationMap',
-               'defaultDateFormat', 'extraUserToggles', 'specialPageAliases',
-               'imageFiles', 'preloadedMessages', 'namespaceGenderAliases',
-               'digitGroupingPattern', 'pluralRules', 'pluralRuleTypes', 'compiledPluralRules',
+               'magicWords', 'messages', 'rtl', 'capitalizeAllNouns',
+               'digitTransformTable', 'separatorTransformTable',
+               'minimumGroupingDigits', 'fallback8bitEncoding',
+               'linkPrefixExtension', 'linkTrail', 'linkPrefixCharset',
+               'namespaceAliases', 'dateFormats', 'datePreferences',
+               'datePreferenceMigrationMap', 'defaultDateFormat',
+               'specialPageAliases', 'imageFiles', 'preloadedMessages',
+               'namespaceGenderAliases', 'digitGroupingPattern', 'pluralRules',
+               'pluralRuleTypes', 'compiledPluralRules',
        ];
 
        /**
         * Keys for items which consist of associative arrays, which may be merged
         * by a fallback sequence.
         */
-       static public $mergeableMapKeys = [ 'messages', 'namespaceNames',
+       public static $mergeableMapKeys = [ 'messages', 'namespaceNames',
                'namespaceAliases', 'dateFormats', 'imageFiles', 'preloadedMessages'
        ];
 
        /**
         * Keys for items which are a numbered array.
         */
-       static public $mergeableListKeys = [ 'extraUserToggles' ];
+       public static $mergeableListKeys = [];
 
        /**
         * Keys for items which contain an array of arrays of equivalent aliases
         * for each subitem. The aliases may be merged by a fallback sequence.
         */
-       static public $mergeableAliasListKeys = [ 'specialPageAliases' ];
+       public static $mergeableAliasListKeys = [ 'specialPageAliases' ];
 
        /**
         * Keys for items which contain an associative array, and may be merged if
         * the primary value contains the special array key "inherit". That array
         * key is removed after the first merge.
         */
-       static public $optionalMergeKeys = [ 'bookstoreList' ];
+       public static $optionalMergeKeys = [ 'bookstoreList' ];
 
        /**
         * Keys for items that are formatted like $magicWords
         */
-       static public $magicWordKeys = [ 'magicWords' ];
+       public static $magicWordKeys = [ 'magicWords' ];
 
        /**
         * Keys for items where the subitems are stored in the backend separately.
         */
-       static public $splitKeys = [ 'messages' ];
+       public static $splitKeys = [ 'messages' ];
 
        /**
         * Keys which are loaded automatically by initLanguage()
         */
-       static public $preloadedKeys = [ 'dateFormats', 'namespaceNames' ];
+       public static $preloadedKeys = [ 'dateFormats', 'namespaceNames' ];
 
        /**
         * Associative array of cached plural rules. The key is the language code,
@@ -192,7 +193,11 @@ class LocalisationCache {
                global $wgCacheDirectory;
 
                $this->conf = $conf;
-               $storeConf = [];
+
+               $directory = !empty( $conf['storeDirectory'] ) ? $conf['storeDirectory'] : $wgCacheDirectory;
+               $storeArg = [];
+               $storeArg['directory'] = $directory;
+
                if ( !empty( $conf['storeClass'] ) ) {
                        $storeClass = $conf['storeClass'];
                } else {
@@ -203,20 +208,17 @@ class LocalisationCache {
                                        break;
                                case 'db':
                                        $storeClass = LCStoreDB::class;
-                                       $storeConf['server'] = $conf['storeServer'] ?? [];
+                                       $storeArg['server'] = $conf['storeServer'] ?? [];
                                        break;
                                case 'array':
                                        $storeClass = LCStoreStaticArray::class;
                                        break;
                                case 'detect':
-                                       if ( !empty( $conf['storeDirectory'] ) ) {
-                                               $storeClass = LCStoreCDB::class;
-                                       } elseif ( $wgCacheDirectory ) {
-                                               $storeConf['directory'] = $wgCacheDirectory;
+                                       if ( $directory ) {
                                                $storeClass = LCStoreCDB::class;
                                        } else {
                                                $storeClass = LCStoreDB::class;
-                                               $storeConf['server'] = $conf['storeServer'] ?? [];
+                                               $storeArg['server'] = $conf['storeServer'] ?? [];
                                        }
                                        break;
                                default:
@@ -227,11 +229,8 @@ class LocalisationCache {
                }
 
                wfDebugLog( 'caches', static::class . ": using store $storeClass" );
-               if ( !empty( $conf['storeDirectory'] ) ) {
-                       $storeConf['directory'] = $conf['storeDirectory'];
-               }
 
-               $this->store = new $storeClass( $storeConf );
+               $this->store = new $storeClass( $storeArg );
                foreach ( [ 'manualRecache', 'forceRecache' ] as $var ) {
                        if ( isset( $conf[$var] ) ) {
                                $this->$var = $conf[$var];
@@ -536,7 +535,6 @@ class LocalisationCache {
                        }
                } elseif ( $_fileType == 'aliases' ) {
                        if ( isset( $aliases ) ) {
-                               /** @suppress PhanUndeclaredVariable */
                                $data['aliases'] = $aliases;
                        }
                } else {
@@ -804,6 +802,7 @@ class LocalisationCache {
                $messagesDirs = $config->get( 'MessagesDirs' );
                return [
                        'core' => "$IP/languages/i18n",
+                       'exif' => "$IP/languages/i18n/exif",
                        'api' => "$IP/includes/api/i18n",
                        'oojs-ui' => "$IP/resources/lib/ooui/i18n",
                ] + $messagesDirs;
@@ -1033,7 +1032,7 @@ class LocalisationCache {
                # HACK: If using a null (i.e. disabled) storage backend, we
                # can't write to the MessageBlobStore either
                if ( $purgeBlobs && !$this->store instanceof LCStoreNull ) {
-                       $blobStore = new MessageBlobStore();
+                       $blobStore = MediaWikiServices::getInstance()->getResourceLoader()->getMessageBlobStore();
                        $blobStore->clear();
                }
        }