diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index 4901e2cf297a..eca3adec1b82 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -32,12 +32,16 @@ class Store implements StoreInterface * Constructor. * * @param string $root The path to the cache directory + * + * @throws \RuntimeException */ public function __construct($root) { $this->root = $root; if (!is_dir($this->root)) { - mkdir($this->root, 0777, true); + if (false === @mkdir($this->root, 0777, true) && !is_dir($this->root)) { + throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root)); + } } $this->keyCache = new \SplObjectStorage(); $this->locks = array(); @@ -74,7 +78,7 @@ public function cleanup() public function lock(Request $request) { $path = $this->getPath($this->getCacheKey($request).'.lck'); - if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true)) { + if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) { return false; } @@ -338,7 +342,7 @@ private function load($key) private function save($key, $data) { $path = $this->getPath($key); - if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true)) { + if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) { return false; } diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index bda87e80e1e9..8677b57e4f4f 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -41,8 +41,8 @@ public function __construct($dsn) } $this->folder = substr($dsn, 5); - if (!is_dir($this->folder)) { - mkdir($this->folder, 0777, true); + if (!is_dir($this->folder) && false === @mkdir($this->folder, 0777, true) && !is_dir($this->folder)) { + throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $this->folder)); } } @@ -125,6 +125,8 @@ public function read($token) /** * {@inheritdoc} + * + * @throws \RuntimeException */ public function write(Profile $profile) { @@ -134,8 +136,8 @@ public function write(Profile $profile) if (!$profileIndexed) { // Create directory $dir = dirname($file); - if (!is_dir($dir)) { - mkdir($dir, 0777, true); + if (!is_dir($dir) && false === @mkdir($dir, 0777, true) && !is_dir($dir)) { + throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $dir)); } }