Avoid globals for this, inject them from the factory function instead.
Bug: T218207
Change-Id: Ia961e8e08dcf1ca154d74ea6a3dadd2d59c1299c
/** @var string Current language code */
private $currentLang;
/** @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 = [] ) {
private $directory;
function __construct( $conf = [] ) {
- global $wgCacheDirectory;
-
- $this->directory = $conf['directory'] ?? $wgCacheDirectory;
+ $this->directory = $conf['directory'];
}
public function get( $code, $key ) {
}
public function get( $code, $key ) {
private $directory;
public function __construct( $conf = [] ) {
private $directory;
public function __construct( $conf = [] ) {
- global $wgCacheDirectory;
-
- $this->directory = $conf['directory'] ?? $wgCacheDirectory;
+ $this->directory = $conf['directory'];
}
public function startWrite( $code ) {
}
public function startWrite( $code ) {
global $wgCacheDirectory;
$this->conf = $conf;
global $wgCacheDirectory;
$this->conf = $conf;
+
+ $directory = !empty( $conf['storeDirectory'] ) ? $conf['storeDirectory'] : $wgCacheDirectory;
+ $storeArg['directory'] = $directory;
+
if ( !empty( $conf['storeClass'] ) ) {
$storeClass = $conf['storeClass'];
} else {
if ( !empty( $conf['storeClass'] ) ) {
$storeClass = $conf['storeClass'];
} else {
$storeClass = LCStoreStaticArray::class;
break;
case 'detect':
$storeClass = LCStoreStaticArray::class;
break;
case 'detect':
- if ( !empty( $conf['storeDirectory'] ) ) {
- $storeClass = LCStoreCDB::class;
- } elseif ( $wgCacheDirectory ) {
- $storeArg['directory'] = $wgCacheDirectory;
$storeClass = LCStoreCDB::class;
} else {
$storeClass = LCStoreDB::class;
$storeClass = LCStoreCDB::class;
} else {
$storeClass = LCStoreDB::class;
}
wfDebugLog( 'caches', static::class . ": using store $storeClass" );
}
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 ) {
$this->store = new $storeClass( $storeArg );
foreach ( [ 'manualRecache', 'forceRecache' ] as $var ) {