8000 bug #21211 Classloader tmpname (lyrixx) · symfony/symfony@e9f2512 · GitHub
[go: up one dir, main page]

Skip to content

Commit e9f2512

Browse files
committed
bug #21211 Classloader tmpname (lyrixx)
This PR was merged into the 2.7 branch. Discussion ---------- Classloader tmpname | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - In dev env: from: > Notice: tempnam(): file created in the system's temporary directory to: > Failed to write cache file "/var/www/html/var/cache/dev/classes.php". Commits ------- 3c887da [ClassLoader] Throw an exception if the cache is not writeable
2 parents 6bd7840 + 3c887da commit e9f2512

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