Merge "localisation: Inject 'directory' option to LCStore classes"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 14 May 2019 18:47:26 +0000 (18:47 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 14 May 2019 18:47:26 +0000 (18:47 +0000)
includes/cache/localisation/LCStoreCDB.php
includes/cache/localisation/LCStoreStaticArray.php
includes/cache/localisation/LocalisationCache.php

index 3455470..aad9439 100644 (file)
@@ -42,13 +42,11 @@ class LCStoreCDB implements LCStore {
        /** @var string Current language code */
        private $currentLang;
 
-       /** @var bool|string Cache directory. False if not set */
+       /** @var string Cache directory */
        private $directory;
 
        function __construct( $conf = [] ) {
-               global $wgCacheDirectory;
-
-               $this->directory = $conf['directory'] ?? $wgCacheDirectory;
+               $this->directory = $conf['directory'];
        }
 
        public function get( $code, $key ) {
index d3504a8..5911656 100644 (file)
@@ -39,9 +39,7 @@ class LCStoreStaticArray implements LCStore {
        private $directory;
 
        public function __construct( $conf = [] ) {
-               global $wgCacheDirectory;
-
-               $this->directory = $conf['directory'] ?? $wgCacheDirectory;
+               $this->directory = $conf['directory'];
        }
 
        public function startWrite( $code ) {
index 8a3a818..788eec3 100644 (file)
@@ -192,7 +192,11 @@ class LocalisationCache {
                global $wgCacheDirectory;
 
                $this->conf = $conf;
+
+               $directory = !empty( $conf['storeDirectory'] ) ? $conf['storeDirectory'] : $wgCacheDirectory;
                $storeArg = [];
+               $storeArg['directory'] = $directory;
+
                if ( !empty( $conf['storeClass'] ) ) {
                        $storeClass = $conf['storeClass'];
                } else {
@@ -209,10 +213,7 @@ class LocalisationCache {
                                        $storeClass = LCStoreStaticArray::class;
                                        break;
                                case 'detect':
-                                       if ( !empty( $conf['storeDirectory'] ) ) {
-                                               $storeClass = LCStoreCDB::class;
-                                       } elseif ( $wgCacheDirectory ) {
-                                               $storeArg['directory'] = $wgCacheDirectory;
+                                       if ( $directory ) {
                                                $storeClass = LCStoreCDB::class;
                                        } else {
                                                $storeClass = LCStoreDB::class;
@@ -227,9 +228,6 @@ class LocalisationCache {
                }
 
                wfDebugLog( 'caches', static::class . ": using store $storeClass" );
-               if ( !empty( $conf['storeDirectory'] ) ) {
-                       $storeArg['directory'] = $conf['storeDirectory'];
-               }
 
                $this->store = new $storeClass( $storeArg );
                foreach ( [ 'manualRecache', 'forceRecache' ] as $var ) {