Error with PHP 5.3
jbn - August 5, 2009 - 07:44
| Project: | ImageAPI |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
| Issue tags: | PHP 5.3 |
Description
I got warnings from my drupal installation after switching servers, turns out the update from PHP 5.2.* to PHP 5.3 was far from harmless.
The warnings were of the kind "expected to be a reference, value given" and in my case was imageapi_gd_image_resize. It prevented images from loading with imagecache.
Seemingly same problem as 360605. Figured it could be useful to know about it for the imageAPI-devs.

#1
I think I hit the same problem. Error looked like this:
Warning: Parameter 1 to imageapi_gd_image_resize() expected to be a reference, value given in [site path]/drupal-6.14/sites/all/modules/imageapi/imageapi.module on line 165
I corrected it by removing the "&" from
function imageapi_gd_image_resize(&$image, $width, $height)inside imageapi_gd.module
#2
yeah that should be alright since $image is an object and all objects are passed by reference in PHP 5. same change probably needs to be made to imageapi_gd_image_crop(), imageapi_gd_image_rotate(), imageapi_gd_image_sharpen(), and imageapi_gd_image_desaturate().
#3
#4
This solution worked for me as well
#5
This solution worked for me. I also had to remove the "&" from the following lines in order to keep ImageCache 100% working:
function imageapi_gd_image_rotate(&$imagefunction imageapi_gd_image_sharpen(&$image#6
to be clear it works fine with our with out them it's just throwing warnings.
#7
thanks a lot for this! been racking my brains the past couple of days about the warning, and on another note, It will not work fine with ubercart installed, the image won't appear. so to be safe just delete the "&", again many thanks!
#8
Worked for me too! Thanks.
#9
Worked so well I made it into a patch...
#10
patches would have to apply to 6.x-1.x-dev so that they can be rolled into the next release by the developer if they pass the muster.
#11
subscribing
#12
The other way is to fix the ImageAPI.module...
Index: imageapi.module===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi.module,v
retrieving revision 1.23.2.3
diff -u -p -r1.23.2.3 imageapi.module
--- imageapi.module 18 Mar 2009 08:35:59 -0000 1.23.2.3
+++ imageapi.module 26 Oct 2009 10:04:03 -0000
@@ -161,7 +161,7 @@ function imageapi_default_toolkit() {
function imageapi_toolkit_invoke($method, &$image, array $params = array()) {
$function = $image->toolkit . '_image_' . $method;
if (function_exists($function)) {
- array_unshift($params, $image);
+ array_unshift($params, &$image);
return call_user_func_array($function, $params);
}
Adding this fixed the problem for me.
#13
Unless you take away the ampersand from the listed functions, the picture does not show up for Ubercart. It throws a warning, and fails to provide the photo that's been uploaded to an Ubercart product page. You must make the change or it's not fine.
Thanks everybody!!
#14
we need to hit the imagemagick code too. i incorporated nicholasThompson's change since it seemed to make sense.
#15
Thanks! It worked for me too with the patch given in #14 by drewish. I hope this can be added to the dev version.
#16
warning: Parameter 1 to imageapi_gd_image_resize() expected to be a reference
same error with lots of modules.
#17
dom_b, was that after applying the patch?
#18
i've applied the patch to the latest cvs and it seems to work great now. thanks.
is this going to be rolled into the next release? as everything is working now I don't want to move to a stable version just for it to not be working again!