-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ClassLoader] Throw an exception if the cache is not writeable #21211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Does that really work? I mean: "file created in the system's temporary directory" happens when |
Before the patch, in dev, I get the notice, and this notice is converted to an exception. So in both case I have to fix the permission. Then, If I fix permissions, It works in both case. |
Ok got it. Your are right. If I add the What you I do? just add the |
@lyrixx the goal of |
and |
af27fbe
to
c5b65de
Compare
I updated the code. |
Oups, I forgot PHP 5.4. I have different implementations: set_error_handler(function () use ($file) {
throw new \RuntimeException(sprintf('Failed to create temporary file in "%s".', dirname($file)));
});
try {
$tmpFile = tempnam(, basename($file));
} catch(\RuntimeException $e) {
restore_error_handler();
throw $e;
}
restore_error_handler(); or something like $tmpFile = @tempnam(dirname($file), basename($file));
if (dirname($file) !== dirname($tmpFile)) {
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
} or $dir = dirname($file);
if (is_writable($dir)) {
throw new \RuntimeException(sprintf('Failed to write cache in directory "%s".', $dir));
} Which one is the best? |
c5b65de
to
9f7ad90
Compare
Did the 3/ |
$tmpFile = tempnam(dirname($file), basename($file)); | ||
$dir = dirname($file); | ||
if (!is_writable($dir)) { | ||
throw new \RuntimeException(sprintf('Failed to write cache in directory "%s".', $file)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$dir
9f7ad90
to
69cc04e
Compare
69cc04e
to
3c887da
Compare
👍 |
Thank you @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
In dev env:
from:
to: