Merge pull request #9404 from neznaika0/refactor/deprecated-filecache-property

refactor: Remove deprecated `Cache::$storePath`
This commit is contained in:
Abdul Malik Ikhsan 2025-01-12 21:15:42 -08:00 committed by GitHub
commit 5e50f2f6a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 16 additions and 36 deletions

View File

@ -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
@ -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.
*
@ -100,6 +89,7 @@ class Cache extends BaseConfig
* -------------------------------------------------------------------------
* Memcached settings
* -------------------------------------------------------------------------
*
* Your Memcached servers can be specified below, if you are using
* the Memcached drivers.
*

View File

@ -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, '/') . '/';

View File

@ -37,14 +37,14 @@ final class CacheFactoryTest extends CIUnitTestCase
// 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']);
}
}
@ -75,8 +75,8 @@ final class CacheFactoryTest extends CIUnitTestCase
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';
@ -85,13 +85,13 @@ final class CacheFactoryTest extends CIUnitTestCase
// 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';
@ -104,6 +104,6 @@ final class CacheFactoryTest extends CIUnitTestCase
// Initialize path
$this->config = new Cache();
$this->config->storePath .= self::$directory;
$this->config->file['storePath'] .= self::$directory;
}
}

View File

@ -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

View File

@ -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

View File

@ -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