-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
ExifProvider.php: handle unhandled exception #35932
Conversation
Signed-off-by: luxifr <luxifer@luxifer.fyi>
Signed-off-by: luxifr <luxifer@luxifer.fyi>
$sizeResult = getimagesizefromstring($file->getContent()); | ||
try { | ||
$sizeResult = getimagesizefromstring($file->getContent()); | ||
} catch (\Throwable $ex) { |
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 don't think this will work:
php > try {getimagesize('foobar');} catch(\Throwable $e){}
PHP Warning: getimagesize(foobar): Failed to open stream: No such file or directory in php shell code on line 1
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.
Probably same reason as in #36420 (comment)
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.
This would work from scan command because scan command converts warning into Exception, but that’s really ugly. It should be handled in Scan command as it is the one doing the conversion.
$sizeResult = getimagesizefromstring($file->getContent()); | ||
} catch (\Throwable $ex) { | ||
$this->logger->warning("Couldn't get image for ".$file->getId(), ['exception' => $ex]); |
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.
Same as in https://github.com/nextcloud/server/pull/36420/files
$sizeResult = getimagesizefromstring($file->getContent()); | |
} catch (\Throwable $ex) { | |
$this->logger->warning("Couldn't get image for ".$file->getId(), ['exception' => $ex]); | |
$sizeResult = @getimagesizefromstring($file->getContent()); | |
} catch (\Exception $ex) { | |
$this->logger->info("Couldn't get image for ".$file->getId(), ['exception' => $ex]); |
$sizeResult = getimagesizefromstring($file->getContent()); | ||
try { | ||
$sizeResult = getimagesizefromstring($file->getContent()); | ||
} catch (\Throwable $ex) { |
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.
This would work from scan command because scan command converts warning into Exception, but that’s really ugly. It should be handled in Scan command as it is the one doing the conversion.
See #37944 instead |
Signed-off-by: luxifr luxifer@luxifer.fyi
Summary
Handle unhandled exception to keep files:scan run from crashing when it encounters a file with invalid exif data.
Checklist