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 and this file not seemingly being included. Reverting that change fixes things. Could anyone shed any light onto where actually gets included and why in this case it isn't?



pfaocle’s picture

Gah, I meant this diff.

Ozeuss’s picture

Title:Problem with including functions in» Missing calls to function located in, rendering imagecache unusable
Version:5.x-2.5» 5.x-2.x-dev
Priority:Normal» Critical
new792 bytes

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.

Ozeuss’s picture

Status:Active» Needs review
Ozeuss’s picture

new1.09 KB

I noticed that there is a missing reference to the action file just for resize on 'imagecache_imagecache_actions',

chrisschaub’s picture

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.

protoplasm’s picture

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.


nodecode’s picture

Similar situation here:

* warning: call_user_func(imagecache_resize_image) []: 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) []: First argument is expected to be a valid callback in /var/www/html/sites/all/modules/imagecache/imagecache_ui.module on line 435.

protoplasm’s picture

I'm am still using 5.x-2.4 because of the above problem. Any ideas about a solution? dev file has similar problems.

rainbreaw’s picture

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.

protoplasm’s picture

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.

cdoyle’s picture

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']) ? '' : $action['file'];

I haven't had time to track down where the call with an empty $action['file'] is coming from.

kingandy’s picture

Same problem can crop up in imagecache_ui - line 435.

Adding more-or-less the same code before the call_user_func() works again:

if (!function_exists($action['action'] .'_form')) {

(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 file to not be included in the first place, but I don't have time to investigate right now... sorry.

sergtop’s picture

The problem from is perfectly solved with the patch from
But you shoud manually clear imagecache_actions row from cache table.

sergtop’s picture

new461 bytes

this one is enough to solve the problem
but if you are upgrading a module you should clear the `cache` table.

orangecoat-ciallella’s picture

#14 + clearing cache tables fixed my issue too. Thanks

pfaocle’s picture

"#14 + manually emptying cache table fixed my issue too." - ditto, using version 5.x-2.5.

drewish’s picture

Status:Needs review» Fixed

Thanks, committed to DRUPAL-5--2.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.