Uh oh!
There was an error while loading. Please reload this page.
ExifProvider.php: handle unhandled exception - #35932
Conversation
Signed-off-by: luxifr <luxifer@luxifer.fyi>
Uh oh!
There was an error while loading. Please reload this page.
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.
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.
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.
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.
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.
come-nc
commented
Apr 27, 2023
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