bug #21025 [Cache] remove is_writable check on filesystem cache (4rthem)

This PR was merged into the 3.1 branch.

Discussion
----------

[Cache] remove is_writable check on filesystem cache

| Q             | A
| ------------- | ---
| Branch?       | 3.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21024
| License       | MIT
| Doc PR        | -

* Use 755 mode for directories creation
* Remove `is_writable` check in FilesystemAdapter to avoid exception on read-only filesystems

Commits
-------

4dc4f69 remove is_writable check on filesystem cache
This commit is contained in:
Nicolas Grekas 2016-12-28 09:22:53 +01:00
commit 98253201f3

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Adapter;
use Symfony\Component\Cache\Exception\CacheException;
use Symfony\Component\Cache\Exception\InvalidArgumentException;
/**
@ -39,9 +40,7 @@ class FilesystemAdapter extends AbstractAdapter
if (false === $dir = realpath($dir) ?: (file_exists($dir) ? $dir : false)) {
throw new InvalidArgumentException(sprintf('Cache directory does not exist (%s)', $directory));
}
if (!is_writable($dir .= DIRECTORY_SEPARATOR)) {
throw new InvalidArgumentException(sprintf('Cache directory is not writable (%s)', $directory));
}
$dir .= DIRECTORY_SEPARATOR;
// On Windows the whole path is limited to 258 chars
if ('\\' === DIRECTORY_SEPARATOR && strlen($dir) > 234) {
throw new InvalidArgumentException(sprintf('Cache directory too long (%s)', $directory));
@ -141,6 +140,10 @@ class FilesystemAdapter extends AbstractAdapter
}
}
if (!$ok && !is_writable($this->directory)) {
throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory));
}
return $ok;
}