Skip to content

Commit

Permalink
Cache Filehandler now respects storePath. Fixes #1078
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Jun 25, 2018
1 parent a022b90 commit f56e2e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 9 additions & 2 deletions system/Cache/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/') . '/';
}
Expand Down Expand Up @@ -322,7 +322,14 @@ protected function getItem(string $key)
*/
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;
}
Expand Down
3 changes: 1 addition & 2 deletions tests/system/Cache/Handlers/FileHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ public function testSave()
{
$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()
Expand Down

0 comments on commit f56e2e9

Please sign in to comment.