-
Notifications
You must be signed in to change notification settings - Fork 379
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
Fix trying to open non-existant manifest file #1600
Conversation
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.
thanks for looking into this. i suggest to explicitly check for the file to have better error reporting.
@@ -68,7 +68,7 @@ public function process(ContainerBuilder $container): void | |||
$runtimeDefinition->setArgument(1, $version); | |||
|
|||
if (is_a($versionStrategyDefinition->getClass(), JsonManifestVersionStrategy::class, true)) { | |||
$jsonManifestString = file_get_contents($version); | |||
$jsonManifestString = @file_get_contents($version); |
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.
i really dislike ignoring errors. could we instead do
$jsonManifestString = @file_get_contents($version); | |
if (!file_exists($version)) { | |
$this->log($container, 'The manifest file at "'.$version.'" does not yet exist'); | |
return; | |
} | |
$jsonManifestString = file_get_contents($version); |
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.
I didn't add it in the first place because file_get_contents
doesn't trigger an error, only a E_WARNING which doesn't halt the script. It's the cache:clear of symfony who transform this into an error afterwards.
And since $jsonManifestString is set to false with or without the error control operator, the unreadable file is handled by the next condition.
But as you wish, the log message will be clearer with your proposed solution !
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.
yeah, i guess the check if the contents of the file is empty would have caught it. but this seems clearer to me.
thanks for looking into the issue and providing the fix!
/cc @wouterSkepp |
Hello,
Following #1529,
cache:clear
auto-script in fresh composer install for example is crashing because the manifest.json does not exist yet.This PR add a check on the existence of the file before trying to open it.