Skip to content

Commit a70faa0

Browse files
committed
fix: FileLocatorCach is not removed if $locatorCacheEnabled is already true
This command removes the cache file, but FileLocatorCached will create a new cache file when destructing.
1 parent 70f2bc8 commit a70faa0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

system/Autoloader/FileLocatorCached.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ private function saveCache(): void
8585
*/
8686
public function deleteCache(): void
8787
{
88+
$this->cacheUpdated = false;
8889
$this->cacheHandler->delete($this->cacheKey);
8990
}
9091

system/Commands/Utilities/Optimize.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace CodeIgniter\Commands\Utilities;
1515

16+
use CodeIgniter\Autoloader\FileLocator;
17+
use CodeIgniter\Autoloader\FileLocatorCached;
1618
use CodeIgniter\CLI\BaseCommand;
1719
use CodeIgniter\CLI\CLI;
1820
use CodeIgniter\Publisher\Publisher;
@@ -72,8 +74,9 @@ public function run(array $params)
7274

7375
private function clearCache(): void
7476
{
75-
$cache = WRITEPATH . 'cache/FileLocatorCache';
76-
$this->removeFile($cache);
77+
$locator = new FileLocatorCached(new FileLocator(service('autoloader')));
78+
$locator->deleteCache();
79+
CLI::write('Removed FileLocatorCache.', 'green');
7780

7881
$cache = WRITEPATH . 'cache/FactoriesCache_config';
7982
$this->removeFile($cache);

0 commit comments

Comments
 (0)