The code in imageapi_image_scale() tries to divide by $image->info['width'] regardless of what width is. If $image->info['width'] is not set for whatever reason, this can cause the php warning: division by zero
Patch attached (against git checkout 6.x-1.x) to simply return FALSE, as there is not enough data to _scale().
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | division-by-zero-1284010-1.patch | 850 bytes | jzacsh |
Comments
Comment #1
jzacsh commentedAttached patch to avoid division by zero.
Comment #2
David Hernández commentedHi there,
I'm not sure if the patch provided on #1 is a good solution. Instead of adding a line to avoid the function causing the error, will be better to find where the error is generated and fix it there. Why the image object doesn't have enough information?
Regards,
David.
Comment #2.0
David Hernández commentedClarifying reason for bug's occurance.
Comment #3
nancydruSee also #1527794: warning: Division by zero in /var/www/default/modules/imageapi/imageapi.module on line 221.
Comment #4
nancydruIn my case, I'm seeing the
&$imageparameter being FALSE.Caller is imagefield/imagefield_file.inc at line 67.
I am also seeing in the log: "The selected image handling toolkit can not correctly process _image_close." This appears to be coming from
imageapi_toolkit_invokewhen$image->toolkitis empty (actually the image object is empty).