minor #13645 fixed possible race condition when creating a directory (fabpot)
This PR was merged into the 2.3 branch.
Discussion
----------
fixed possible race condition when creating a directory
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #13228
| License | MIT
| Doc PR | n/a
Commits
-------
8542866
fixed possible race condition when creating a directory
This commit is contained in:
commit
e18d2ad80d
@ -666,7 +666,7 @@ class FrameworkExtension extends Extension
|
||||
|
||||
if ('file' === $config['cache']) {
|
||||
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
|
||||
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true)) {
|
||||
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
|
||||
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ class File extends \SplFileInfo
|
||||
protected function getTargetFile($directory, $name = null)
|
||||
{
|
||||
if (!is_dir($directory)) {
|
||||
if (false === @mkdir($directory, 0777, true)) {
|
||||
if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) {
|
||||
throw new FileException(sprintf('Unable to create the "%s" directory', $directory));
|
||||
}
|
||||
} elseif (!is_writable($directory)) {
|
||||
|
@ -605,7 +605,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
{
|
||||
foreach (array('cache' => $this->getCacheDir(), 'logs' => $this->getLogDir()) as $name => $dir) {
|
||||
if (!is_dir($dir)) {
|
||||
if (false === @mkdir($dir, 0777, true)) {
|
||||
if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
|
||||
throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir));
|
||||
}
|
||||
} elseif (!is_writable($dir)) {
|
||||
|
Reference in New Issue
Block a user