ExifProvider.php: handle unhandled exception#35932
Closed
luxifr wants to merge 2 commits intonextcloud:masterfrom
luxifr:patch-1
Closed
ExifProvider.php: handle unhandled exception#35932luxifr wants to merge 2 commits intonextcloud:masterfrom luxifr:patch-1
luxifr wants to merge 2 commits intonextcloud:masterfrom
luxifr:patch-1
Conversation
Signed-off-by: luxifr <luxifer@luxifer.fyi>
shyim
reviewed
Dec 31, 2022
Signed-off-by: luxifr <luxifer@luxifer.fyi>
artonge
approved these changes
Jan 4, 2023
Merged
marcelklehr
reviewed
Feb 3, 2023
| $sizeResult = getimagesizefromstring($file->getContent()); | ||
| try { | ||
| $sizeResult = getimagesizefromstring($file->getContent()); | ||
| } catch (\Throwable $ex) { |
Member
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
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.
4 tasks
Merged
Merged
9 tasks
szaimen
reviewed
Apr 15, 2023
Comment on lines
+72
to
+74
| $sizeResult = getimagesizefromstring($file->getContent()); | ||
| } catch (\Throwable $ex) { | ||
| $this->logger->warning("Couldn't get image for ".$file->getId(), ['exception' => $ex]); |
Contributor
There was a problem hiding this comment.
Same as in https://github.com/nextcloud/server/pull/36420/files
Suggested change
| $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]); |
come-nc
requested changes
Apr 27, 2023
| $sizeResult = getimagesizefromstring($file->getContent()); | ||
| try { | ||
| $sizeResult = getimagesizefromstring($file->getContent()); | ||
| } catch (\Throwable $ex) { |
Contributor
There was a problem hiding this comment.
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.
Contributor
|
See #37944 instead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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