-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Bug: ImageHandler has no reality checks #2421
Comments
Anytime the developer forgot to do a step it should crash loudly so they can catch it... |
So errors like "division by zero" are okay if they skip |
Actually to take it one step deeper... |
Deeper still...
I'm thinking we either need a lot more involvement or just some way of failing more explicitly. |
In general yes. Every example in the docs show that you have to use I suppose we could give a more helpful exception message (that an image is required), but that would require a check on pretty much every function. The File constructor already has the option to check if a file exists, but that's an optional check. In the BaseHandller, though we do check the file exists. That requires the user has actually used |
Hmm this is tricky. On the one hand, it seems like a valid On the other hand having the handlers be generic classes makes them easy to use with the service, but creates this situation where it is easy to mess up. |
Floating an idea... Since all the methods use |
Describe the bug
ImageHandler does not do any verification that it has a valid image loaded, which can lead to some errors with unhelpful descriptions. E.g.
fit()
will try to calculate the aspect ration with a null value, so$xRatio = $width / $origWidth;
results in "Division by zero".I don't know where validation should happen -
withFile()
is maybe the best bet but doesn't catch instances where developers forget to use it before calling other methods.CodeIgniter 4 version
develop
Affected module(s)
Image Manipulation Class
The text was updated successfully, but these errors were encountered: