Skip to content

Commit 3db3fb1

Browse files
committed
CacheExtension: throws exception when is unable to create directory or directory is not writable
1 parent 222c801 commit 3db3fb1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Bridges/CacheDI/CacheExtension.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ public function __construct($tempDir)
2929

3030
public function loadConfiguration()
3131
{
32-
@mkdir($this->tempDir . '/cache'); // @ - directory may exists
32+
$dir = $this->tempDir . '/cache';
33+
Nette\Utils\FileSystem::createDir($dir);
34+
35+
$uniq = uniqid('_', true);
36+
if (!@mkdir("$dir/$uniq")) { // @ - is escalated to exception
37+
throw new Nette\InvalidStateException("Unable to write to directory '$dir'. Make this directory writable.");
38+
}
39+
rmdir("$dir/$uniq");
3340

3441
$builder = $this->getContainerBuilder();
3542

0 commit comments

Comments
 (0)