Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
imageapi_image_overlay() fails under PHP 5.3 as it passes a copy (vs a reference) to the image when invoking imageapi_toolkit_invoke(). This exhibits as HTTP 500 errors for any imagecache preset that uses a overlay watermark action.
Comment | File | Size | Author |
---|---|---|---|
#10 | Screen Shot 2011-12-17 at 3.31.47 PM.png | 39.52 KB | alphex |
#1 | imagecache_canvasactions-1153518.patch | 677 bytes | thsutton |
Comments
Comment #1
thsutton CreditAttribution: thsutton commentedThe attached patch changes imageapi_image_overlay() to pass $image by reference to resolve HTTP 500 errors for imagecache presets which use an overlay watermark action.
Comment #2
modctek CreditAttribution: modctek commented+1, this issue was driving me crazy, trying to figure out why my overlays weren't working.
Comment #3
SchwebDesign CreditAttribution: SchwebDesign commentedTHANK YOU!!! subscribing- this was driving me crazy as well and the patch fixed the issue for me.
These are the errors I was getting:
ImageAPI 6.x-1.10
ImageAPI GD2 6.x-1.10
ImageCache 6.x-2.0-beta12
Imagecache Canvas Actions 6.x-2.0
GD library bundled (2.0.34 compatible)
Drupal 6.22
MySQL database 5.1.56
PHP 5.3.6
Comment #4
2020media CreditAttribution: 2020media commentedBlimey this was a hard one to track down - I was getting no errors in the logs and I couldn't figure out why some imagecache presets were working and not others - eventually found it was related to overlay watermark and hence found this post. The site was migrated from a PHP5.2 server to a PHP5.3 server. Your solution worked perfectly.
Thank you thsutton.
Comment #5
garbo CreditAttribution: garbo commentedThe solution worked for me too! But imagecache_actions isn't the only module that's have troubles with PHP5.3. I wonder why so many modules are having troubles with PHP 5.3 and the reference object.
Comment #6
thsutton CreditAttribution: thsutton commentedBecause code that shouldn't have worked but did in PHP 5.2 now correctly doesn't work in PHP 5.3.
Comment #7
thsutton CreditAttribution: thsutton commentedComment #8
crea CreditAttribution: crea commentedThe fix #1 works for me but in latest 2.x this is now in a different file: imageapi_image_overlay.inc
Comment #9
joelstein CreditAttribution: joelstein commentedThe patch in #1 worked for me.
Comment #10
alphex CreditAttribution: alphex commentedRunning PHP 5.3.8.
This is still an issue for us. Has anyone had any luck with PHP 5.3.8 and this solution?
We're running version 1.8 of the module as well.
Does 2.0 fix this?
ImageAPI 6.x-1.10
ImageAPI GD2 6.x-1.10
ImageCache 6.x-2.0-beta12
Imagecache Canvas Actions 6.x-1.8
On D6.22
PHP 5.3.8
Apache/2.2.15 (Red Hat)
Comment #11
alphex CreditAttribution: alphex commentedOk, now I'm confused.
I just looked at the patch code, and realized that whats in it is old, cause the 6.x-1.8 module has this fix in it already?
but 1.8 was published in Feb 2011, and this patch wasn't written until May?
I just re-downloaded the module and double checked. If I search for the string
return imageapi_toolkit_invoke('overlay', $image, array(&$layer, $x, $y, $alpha, $reverse));
It shows up at line 134 with the AMPERSAND sign already in place (which is the only difference I saw.
did this not warrant a version number increment? and just got put in the code anyway?
If I'm being blind about something, please educate me :)
Comment #12
dman CreditAttribution: dman commentedIIRC, this fix was trivial, and went in quietly when some other updates were being done, or when it was noticed in the logs during testing some time.
On many PHP installs, the notice can be or is suppressed, so it didn't seem to bite very hard at the time. As more PHP5.3 strict users came online, it became more of an issue, but it was already fixed in -dev branches by then. There is also the chance that it was 'fixed' at one point but overwritten/reverted for a while by a different code merge? I dunno.
There was probably some sore of overlap between the fix actually happening (in dev), this patch being raised to fix something that was already in the 'pending' state, and the 1.8 actual release. Or something like that in a different order.
This is why I'd love to be able to have a testsuite to manage regressions ... but can't do it with images :-(
Anyway, I guess that means the problem is not seen in any of the stable releases out there today?
Meaning... fixed? I think?
Comment #13
TwoDThis issue was originally about ImageCache Actions 6.x-2.0, where this issue STILL exists.
The patch in #1 is the correct way to fix this, see my post in #540486-72: Error with PHP 5.3 (ImageAPI) and the patch in #648950-12: Error with PHP 5.3.
The issue was incorrectly fixed by no longer accepting $layer as an argument in ImageCache Actions 6.x-2.x 5ce275a7..., please revert that commit as it could break backwards compatibility (and might decrease performance due to the layer having to be copied - also, it's technically valid to modify the layer in the ImageAPI 'overlay' callback).
I can confirm the #1 patch fixes ImageCache on PHP 5.3 (images with overlays don't get created at all without it).
Comment #14
fietserwinThe 6.x-2.x is not supported anymore and we are closing all issues for it. Please feel free to reopen against the 6.x-1.x branch if the error also appears there.