Skip to content

Commit 5e50f2f

Browse files
authored
Merge pull request #9404 from neznaika0/refactor/deprecated-filecache-property
refactor: Remove deprecated `Cache::$storePath`
2 parents b635a17 + 23f2559 commit 5e50f2f

File tree

6 files changed

+16
-36
lines changed

6 files changed

+16
-36
lines changed

app/Config/Cache.php

Lines changed: 2 additions & 12 deletions
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

Lines changed: 0 additions & 7 deletions
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

Lines changed: 10 additions & 10 deletions
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
}

user_guide_src/source/changelogs/v4.6.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Removed Deprecated Items
201201
- **Router:** The deprecated ``CodeIgniter\Router\Exceptions\RedirectException`` has been removed. Use ``CodeIgniter\HTTP\Exceptions\RedirectException`` instead.
202202
- **Constants:** The deprecated constants ``EVENT_PRIORITY_*`` in has been removed. Use the class constants ``CodeIgniter\Events\Events::PRIORITY_LOW``, ``CodeIgniter\Events\Events::PRIORITY_NORMAL`` and ``CodeIgniter\Events\Events::PRIORITY_HIGH`` instead.
203203
- **View:** The deprecated property ``CodeIgniter\View\View::$currentSection`` has been removed.
204+
- **Config:** The deprecated property ``Config\Cache::$storePath`` has been removed. Use ``Config\Cache::$file['storePath']`` instead.
204205

205206
************
206207
Enhancements

user_guide_src/source/installation/upgrade_460.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,5 @@ This is a list of all files in the **project space** that received changes;
222222
many will be simple comments or formatting that have no effect on the runtime:
223223

224224
- app/Config/Feature.php
225-
- app/Config/Constants.php
225+
- app/Config/Constants.php
226+
- app/Config/Cache.php

utils/phpstan-baseline/function.alreadyNarrowedType.neon

Lines changed: 1 addition & 6 deletions
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)