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

Skip to content

Commit c5b65de

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

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,15 @@ private static function compressCode($code)
275275
*/
276276
private static function writeCacheFile($file, $content)
277277
{
278-
$tmpFile = tempnam(dirname($file), basename($file));
278+
set_error_handler(function () use ($file) {
279+
throw new \RuntimeException(sprintf('Failed to create temporary file in "%s".', dirname($file)));
280+
});
281+
try {
282+
$tmpFile = tempnam(dirname($file), basename($file));
283+
} finally {
284+
restore_error_handler();
285+
}
286+
279287
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
280288
@chmod($file, 0666 & ~umask());
281289

0 commit comments

Comments
 (0)
0