Cache Filehandler now respects storePath. Fixes #1078

This commit is contained in:
Lonnie Ezell 2018-06-24 23:23:12 -05:00
parent a022b907ba
commit f56e2e9d92
No known key found for this signature in database
GPG Key ID: 8EB408F8D82F5002
2 changed files with 10 additions and 4 deletions

View File

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

View File

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