Missing calls to function located in imagecache_actions.inc, rendering imagecache unusable
leafish_paul - August 20, 2009 - 16:34
| Project: | ImageCache |
| Version: | 5.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Since updating to 2.5 (for SA-CONTRIB-2009-051) with the 5.x branch of imagecache one of our sites has been throwing PHP errors for any new images uploaded when trying to display them via imagecache:
call_user_func(imagecache_resize_image): First argument is expected to be a valid callback...
I guess this stems from this change ie moving these functions from imagecache.module to imagecache_actions.inc and this file not seemingly being included. Reverting that change fixes things. Could anyone shed any light onto where imagecache_actions.inc actually gets included and why in this case it isn't?

#1
Gah, I meant this diff.
#2
The reason is like mentioned above. Although the correct file is recorded in the $action array, there is no specific call to the file itself- so imagecache doesn't display *any* images.
I've marked as critical, since this breaks sites (in a stable version).
A patch is attached.
#3
#4
I noticed that there is a missing reference to the action file just for resize on 'imagecache_imagecache_actions',
rerolling.
#5
This patch fixes the problem. This is a very big bug, can this please get rolled as a point release? Currently, this is breaking all 5.x sites.
Thank you.
#6
I have had similar problems with upgrading from 5.x-2.4 to 5.x-2.5. Applying this patch to 5.x-2.5 causes me this error, but at least now allows function:
* warning: include_once() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php') in public_html/sites/all/modules/imagecache/imagecache.module on line 383.
* warning: include_once() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php') in public_html/sites/all/modules/imagecache/imagecache.module on line 383.
Thanx.
#7
Similar situation here:
* warning: call_user_func(imagecache_resize_image) [function.call-user-func]: First argument is expected to be a valid callback in /var/www/html/sites/all/modules/imagecache/imagecache.module on line 381.
* warning: call_user_func(imagecache_resize_form) [function.call-user-func]: First argument is expected to be a valid callback in /var/www/html/sites/all/modules/imagecache/imagecache_ui.module on line 435.
#8
I'm am still using 5.x-2.4 because of the above problem. Any ideas about a solution? dev file has similar problems.
#9
I found that it is critical that you upgrade ImageField before upgrading ImageCache. That, combined with the help above, seems to have solved my difficulties with the ImageCache upgrade.
#10
Since the proper functioning of imagecache is so crucial to my website, I decided to forge ahead with an upgrade from 5.20 to 6.14 with imagecache 5.x-2.5 in place (the version causing my difficulties) and my problems with imagecache went away.
#11
I was having the same problem as #6 and #7 so I did a dirty patch to get around it. I replaced line 383 (after patching) with the following:
$action['file'] = empty($action['file']) ? 'imagecache_actions.inc' : $action['file'];include_once($action['file']);
I haven't had time to track down where the call with an empty $action['file'] is coming from.
#12
Same problem can crop up in imagecache_ui - line 435.
Adding more-or-less the same code before the call_user_func() works again:
<?phpif (!function_exists($action['action'] .'_form')) {
include_once($action['file']);
}
?>
(Shouldn't the if (!function_exists()) check in imagecache.module check for the actual function to be called as well? It checks for $action['action'] then proceeds to call $action['action'].'_image'. I know in this instance the existence of one will imply the existence of the other but ... it feels sloppy.)
Regarding the "Failed opening '' for inclusion" errors - I suspect these were due to the imagecache_action_definitions() function cacheing the results of the hook_imagecache_actions - which meant the resize action was cached without the 'file' entry on it. Clearing the cache solved the issue on my site. TBH I have the suspicion that the lack of a 'file' on the resize action is what caused the imagecache_actions.inc file to not be included in the first place, but I don't have time to investigate right now... sorry.
#13
The problem from http://drupal.org/node/554932#comment-2159276 is perfectly solved with the patch from http://drupal.org/node/554932#comment-2013396.
But you shoud manually clear imagecache_actions row from cache table.
#14
this one is enough to solve the problem
but if you are upgrading a module you should clear the `cache` table.