Skip to content

Commit

Permalink
Merge pull request #9404 from neznaika0/refactor/deprecated-filecache…
Browse files Browse the repository at this point in the history
…-property

refactor: Remove deprecated `Cache::$storePath`
  • Loading branch information
samsonasik authored Jan 13, 2025
2 parents b635a17 + 23f2559 commit 5e50f2f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 36 deletions.
14 changes: 2 additions & 12 deletions app/Config/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ class Cache extends BaseConfig
*/
public string $backupHandler = 'dummy';

/**
* --------------------------------------------------------------------------
* Cache Directory Path
* --------------------------------------------------------------------------
*
* The path to where cache files should be stored, if using a file-based
* system.
*
* @deprecated Use the driver-specific variant under $file
*/
public string $storePath = WRITEPATH . 'cache/';

/**
* --------------------------------------------------------------------------
* Key Prefix
Expand Down Expand Up @@ -86,6 +74,7 @@ class Cache extends BaseConfig
* --------------------------------------------------------------------------
* File settings
* --------------------------------------------------------------------------
*
* Your file storage preferences can be specified below, if you are using
* the File driver.
*
Expand All @@ -100,6 +89,7 @@ class Cache extends BaseConfig
* -------------------------------------------------------------------------
* Memcached settings
* -------------------------------------------------------------------------
*
* Your Memcached servers can be specified below, if you are using
* the Memcached drivers.
*
Expand Down
7 changes: 0 additions & 7 deletions system/Cache/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ class FileHandler extends BaseHandler
*/
public function __construct(Cache $config)
{
if (! property_exists($config, 'file')) {
$config->file = [
'storePath' => $config->storePath ?? WRITEPATH . 'cache',
'mode' => 0640,
];
}

$this->path = ! empty($config->file['storePath']) ? $config->file['storePath'] : WRITEPATH . 'cache';
$this->path = rtrim($this->path, '/') . '/';

Expand Down
20 changes: 10 additions & 10 deletions tests/system/Cache/CacheFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ protected function setUp(): void

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

protected function tearDown(): void
{
if (is_dir($this->config->storePath)) {
chmod($this->config->storePath, 0777);
rmdir($this->config->storePath);
if (is_dir($this->config->file['storePath'])) {
chmod($this->config->file['storePath'], 0777);
rmdir($this->config->file['storePath']);
}
}

Expand Down Expand Up @@ -75,8 +75,8 @@ public function testGetHandlerExceptionCacheHandlerNotFound(): void

public function testGetDummyHandler(): void
{
if (! is_dir($this->config->storePath)) {
mkdir($this->config->storePath, 0555, true);
if (! is_dir($this->config->file['storePath'])) {
mkdir($this->config->file['storePath'], 0555, true);
}

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

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

public function testHandlesBadHandler(): void
{
if (! is_dir($this->config->storePath)) {
mkdir($this->config->storePath, 0555, true);
if (! is_dir($this->config->file['storePath'])) {
mkdir($this->config->file['storePath'], 0555, true);
}

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

// Initialize path
$this->config = new Cache();
$this->config->storePath .= self::$directory;
$this->config->file['storePath'] .= self::$directory;
}
}
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ Removed Deprecated Items
- **Router:** The deprecated ``CodeIgniter\Router\Exceptions\RedirectException`` has been removed. Use ``CodeIgniter\HTTP\Exceptions\RedirectException`` instead.
- **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.
- **View:** The deprecated property ``CodeIgniter\View\View::$currentSection`` has been removed.
- **Config:** The deprecated property ``Config\Cache::$storePath`` has been removed. Use ``Config\Cache::$file['storePath']`` instead.

************
Enhancements
Expand Down
3 changes: 2 additions & 1 deletion user_guide_src/source/installation/upgrade_460.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,5 @@ This is a list of all files in the **project space** that received changes;
many will be simple comments or formatting that have no effect on the runtime:

- app/Config/Feature.php
- app/Config/Constants.php
- app/Config/Constants.php
- app/Config/Cache.php
7 changes: 1 addition & 6 deletions utils/phpstan-baseline/function.alreadyNarrowedType.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# total 3 errors
# total 2 errors

parameters:
ignoreErrors:
-
message: '#^Call to function property_exists\(\) with Config\\Cache and ''file'' will always evaluate to true\.$#'
count: 1
path: ../../system/Cache/Handlers/FileHandler.php

-
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
count: 1
Expand Down

0 comments on commit 5e50f2f

Please sign in to comment.