Skip to content

Commit 4dc4f69

Browse files
committed
remove is_writable check on filesystem cache
1 parent 73a7169 commit 4dc4f69

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Psr\Log\LoggerAwareTrait;
1717
use Psr\Log\LoggerInterface;
1818
use Symfony\Component\Cache\CacheItem;
19+
use Symfony\Component\Cache\Exception\CacheException;
1920

2021
/**
2122
* @author Nicolas Grekas <p@tchwork.com>
@@ -129,6 +130,8 @@ abstract protected function doDelete(array $ids);
129130
* @param int $lifetime The lifetime of the cached values, 0 for persisting until manual cleaning
130131
*
131132
* @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not
133+
*
134+
* @throws CacheException If write can not be performed
132135
*/
133136
abstract protected function doSave(array $values, $lifetime);
134137

src/Symfony/Component/Cache/Adapter/FilesystemAdapter.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Cache\Adapter;
1313

14+
use Symfony\Component\Cache\Exception\CacheException;
1415
use Symfony\Component\Cache\Exception\InvalidArgumentException;
1516

1617
/**
@@ -39,9 +40,7 @@ public function __construct($namespace = '', $defaultLifetime = 0, $directory =
3940
if (false === $dir = realpath($dir) ?: (file_exists($dir) ? $dir : false)) {
4041
throw new InvalidArgumentException(sprintf('Cache directory does not exist (%s)', $directory));
4142
}
42-
if (!is_writable($dir .= DIRECTORY_SEPARATOR)) {
43-
throw new InvalidArgumentException(sprintf('Cache directory is not writable (%s)', $directory));
44-
}
43+
$dir .= DIRECTORY_SEPARATOR;
4544
// On Windows the whole path is limited to 258 chars
4645
if ('\\' === DIRECTORY_SEPARATOR && strlen($dir) > 234) {
4746
throw new InvalidArgumentException(sprintf('Cache directory too long (%s)', $directory));
@@ -141,6 +140,10 @@ protected function doSave(array $values, $lifetime)
141140
}
142141
}
143142

143+
if (!$ok && !is_writable($this->directory)) {
144+
throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory));
145+
}
146+
144147
return $ok;
145148
}
146149

0 commit comments

Comments
 (0)