-
Notifications
You must be signed in to change notification settings - Fork 5
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
Don't throw exception for broken images, but return "empty" image info. #52
Don't throw exception for broken images, but return "empty" image info. #52
Conversation
If we agree on the general approach of this change, I'll fix the tests! :-) |
Well, I guess the same question has to be asked of the second exception in … but not so useful for a stable UI. 😞 |
Generally I agree, but I think I'm going to switch sides for this case. We are just trying to display the info to the user, not really do anything with it (like make image modifications). An exception makes it hard for Twig since it doesn't handle it. That said, we still need a way to determine if the image info is valid or not. All the "empty" cases should be "invalid" too. Maybe rename (copy & deprecate) |
We should make sure thumbs handles the invalid object correctly instead of relying on an exception to be thrown. |
|
5892254
to
061e906
Compare
I added an |
061e906
to
740c90d
Compare
OK, the Thing is, the only time we care about changing that parameter is when we try to public static function createInvalid()
{
$invalid = new static(new Dimensions(0, 0), Type::unknown(), 0, 0, null, new Exif([]));
$invalid->valid = false;
return $invalid;
} Note: Not marking approve/request as I'm happy to be convinced otherwise |
Yeah that's fine. Feel free to change and merge. |
…ject instead of throwing exception when image parsing fails. For this use case we hardly ever care why image parsing failed we just want to show info about the image or default values. This is also mostly done from Twig where exceptions cannot be caught. The valid property allows us to handle the failure without breaking the view layer.
740c90d
to
7a6c482
Compare
Changed, making sure I didn't miss something (valid) on test, then I have just enough time to get this over the line 👍 |
Partial fix for bolt/bolt#6677
Just like when a file is 0 bytes, it should return an 'empty' image info, instead of throwing an exception.
The exception will just "break" the interface, and it won't tell the (end)user much.
Discussed this with Carson last night, and catching and filtering them out in the Bolt UI isn't optimal either, because it needs to be done in three places at least (the "files listing" page, the ajaxy listing in "pick from server" modals, and in the stack).
I'm for returning an "empty" image info, and present the user with a friendly warning in the user interface, that will also tell them which image is broken.