mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Cache Filehandler now respects storePath. Fixes #1078
This commit is contained in:
parent
a022b907ba
commit
f56e2e9d92
@ -59,7 +59,7 @@ class FileHandler implements CacheInterface
|
||||
public function __construct($config)
|
||||
{
|
||||
$this->prefix = $config->prefix ?: '';
|
||||
$this->path = ! empty($config->path) ? $config->path : WRITEPATH . 'cache';
|
||||
$this->path = ! empty($config->storePath) ? $config->storePath : WRITEPATH . 'cache';
|
||||
|
||||
$this->path = rtrim($this->path, '/') . '/';
|
||||
}
|
||||
@ -322,7 +322,14 @@ class FileHandler implements CacheInterface
|
||||
*/
|
||||
protected function writeFile($path, $data, $mode = 'wb')
|
||||
{
|
||||
if (($fp = @fopen($path, $mode)) === false)
|
||||
try
|
||||
{
|
||||
if (($fp = @fopen($path, $mode)) === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (\ErrorException $e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -92,9 +92,8 @@ class FileHandlerTest extends \CIUnitTestCase
|
||||
{
|
||||
$this->assertTrue($this->fileHandler->save(self::$key1, 'value'));
|
||||
|
||||
// The FileHandler always ensures the directory is writable...
|
||||
chmod($this->config->storePath, 0444);
|
||||
$this->assertTrue($this->fileHandler->save(self::$key2, 'value'));
|
||||
$this->assertFalse($this->fileHandler->save(self::$key2, 'value'));
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
|
Loading…
x
Reference in New Issue
Block a user