Skip to content

Commit 528cf7e

Browse files
committed
refactor: Remove deprecated Cache::$storePath
1 parent f67bc68 commit 528cf7e

File tree

4 files changed

+13
-35
lines changed

4 files changed

+13
-35
lines changed

app/Config/Cache.php

+2-12
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@ class Cache extends BaseConfig
3434
*/
3535
public string $backupHandler = 'dummy';
3636

37-
/**
38-
* --------------------------------------------------------------------------
39-
* Cache Directory Path
40-
* --------------------------------------------------------------------------
41-
*
42-
* The path to where cache files should be stored, if using a file-based
43-
* system.
44-
*
45-
* @deprecated Use the driver-specific variant under $file
46-
*/
47-
public string $storePath = WRITEPATH . 'cache/';
48-
4937
/**
5038
* --------------------------------------------------------------------------
5139
* Key Prefix
@@ -86,6 +74,7 @@ class Cache extends BaseConfig
8674
* --------------------------------------------------------------------------
8775
* File settings
8876
* --------------------------------------------------------------------------
77+
*
8978
* Your file storage preferences can be specified below, if you are using
9079
* the File driver.
9180
*
@@ -100,6 +89,7 @@ class Cache extends BaseConfig
10089
* -------------------------------------------------------------------------
10190
* Memcached settings
10291
* -------------------------------------------------------------------------
92+
*
10393
* Your Memcached servers can be specified below, if you are using
10494
* the Memcached drivers.
10595
*

system/Cache/Handlers/FileHandler.php

-7
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ class FileHandler extends BaseHandler
5454
*/
5555
public function __construct(Cache $config)
5656
{
57-
if (! property_exists($config, 'file')) {
58-
$config->file = [
59-
'storePath' => $config->storePath ?? WRITEPATH . 'cache',
60-
'mode' => 0640,
61-
];
62-
}
63-
6457
$this->path = ! empty($config->file['storePath']) ? $config->file['storePath'] : WRITEPATH . 'cache';
6558
$this->path = rtrim($this->path, '/') . '/';
6659

tests/system/Cache/CacheFactoryTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ protected function setUp(): void
3737

3838
// Initialize path
3939
$this->config = new Cache();
40-
$this->config->storePath .= self::$directory;
40+
$this->config->file['storePath'] .= self::$directory;
4141
}
4242

4343
protected function tearDown(): void
4444
{
45-
if (is_dir($this->config->storePath)) {
46-
chmod($this->config->storePath, 0777);
47-
rmdir($this->config->storePath);
45+
if (is_dir($this->config->file['storePath'])) {
46+
chmod($this->config->file['storePath'], 0777);
47+
rmdir($this->config->file['storePath']);
4848
}
4949
}
5050

@@ -75,8 +75,8 @@ public function testGetHandlerExceptionCacheHandlerNotFound(): void
7575

7676
public function testGetDummyHandler(): void
7777
{
78-
if (! is_dir($this->config->storePath)) {
79-
mkdir($this->config->storePath, 0555, true);
78+
if (! is_dir($this->config->file['storePath'])) {
79+
mkdir($this->config->file['storePath'], 0555, true);
8080
}
8181

8282
$this->config->handler = 'dummy';
@@ -85,13 +85,13 @@ public function testGetDummyHandler(): void
8585

8686
// Initialize path
8787
$this->config = new Cache();
88-
$this->config->storePath .= self::$directory;
88+
$this->config->file['storePath'] .= self::$directory;
8989
}
9090

9191
public function testHandlesBadHandler(): void
9292
{
93-
if (! is_dir($this->config->storePath)) {
94-
mkdir($this->config->storePath, 0555, true);
93+
if (! is_dir($this->config->file['storePath'])) {
94+
mkdir($this->config->file['storePath'], 0555, true);
9595
}
9696

9797
$this->config->handler = 'dummy';
@@ -104,6 +104,6 @@ public function testHandlesBadHandler(): void
104104

105105
// Initialize path
106106
$this->config = new Cache();
107-
$this->config->storePath .= self::$directory;
107+
$this->config->file['storePath'] .= self::$directory;
108108
}
109109
}

utils/phpstan-baseline/function.alreadyNarrowedType.neon

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
# total 3 errors
1+
# total 2 errors
22

33
parameters:
44
ignoreErrors:
5-
-
6-
message: '#^Call to function property_exists\(\) with Config\\Cache and ''file'' will always evaluate to true\.$#'
7-
count: 1
8-
path: ../../system/Cache/Handlers/FileHandler.php
9-
105
-
116
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
127
count: 1

0 commit comments

Comments
 (0)