8000 [ClassLoader] Throw an exception if the cache is not writeable · symfony/symfony@3c887da · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c887da

Browse files
committed
[ClassLoader] Throw an exception if the cache is not writeable
1 parent 6bd7840 commit 3c887da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,13 @@ private static function compressCode($code)
275275
*/
276276
private static function writeCacheFile($file, $content)
277277
{
278-
$tmpFile = tempnam(dirname($file), basename($file));
278+
$dir = dirname($file);
279+
if (!is_writable($dir)) {
280+
throw new \RuntimeException(sprintf('Cache directory "%s" is not writable.', $dir));
281+
}
282+
283+
$tmpFile = tempnam($dir, basename($file));
284+
279285
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
280286
@chmod($file, 0666 & ~umask());
281287

0 commit comments

Comments
 (0)
0