Hi, I tried to put a canvas action to a preset and I got a blank page. The logs said the following:

PHP Fatal error: Call to undefined function imagecache_rgb_form() in /whatever/web/sites/default/modules/imagecache_actions/canvasactions/canvasactions.inc on line 67, referer: http://whatever/admin/config/media/image-styles/edit/galleryformatter_slide

I've fixed it adding this code to canvasactions.inc:

if (! function_exists('imagecache_rgb_form') ) {
  module_load_include('inc', 'imagecache_actions', 'utility-color');
}

Comments

dman’s picture

Version: 7.x-0.0 » 7.x-1.x-dev
Status: Active » Fixed

Yeah, something like that was needed.
Should be ok in 7.x-1.x-dev

Status: Fixed » Closed (fixed)

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

alan d.’s picture

Version: 7.x-1.x-dev » 7.x-0.0

Looks like someone removed this again. I haven't check git to see the status (dev is older than the release)

I would just use this prior to the load:

  module_load_include('inc', 'imagecache_actions', 'utility-color');

Mmmm... looking through the code, it looks like you are doing a code order via mixed loads:

if (! function_exists('imagecache_actions_calculate_relative_position') ) {
  module_load_include('inc', 'imagecache_actions', 'utility');
}
module_load_include('inc', 'imagecache_actions', 'utility-color');

// @todo There doesn't seem to be a way to specify a file in hook_image_effect_info
// so placing this here for the time being.
module_load_include('inc', 'imagecache_coloractions', 'transparency');

Since these are effectively unconditionally loaded on every page load, direct includes would be cleaner:

In imagecache_actions.module

require_once 'utility.inc';
require_once 'utility-color.inc';

etc

Or move to a lazy loaded function. No need for special drupal static includes.

function imagecache_load_inc() {
  static $inc = FALSE;
  if (!$inc) {
    $inc = TRUE;
    ... loads here.
  }
}

# And when required:

function do_something() {
  imagecache_load_inc();
}

Or a third option use hook_hook(), but test - this hook fails on the field hooks as these are not real hooks. This could be a really nice way of including / encapsulating the style definitions.

dman’s picture

Yeah. At some point when migrating a bunch of the utilities out into inc files I lost track of the dependencies.
At first each of the action bundles were their own modules, but later they needed to share some libraries that no one module owned.
That's where the conditional checking started, as you may have module A, module B or both enabled.
Anyway, that started getting silly, so I introduced 'imagecache_actions' as a core dependency module that doesn't actually do anything but act as a dependency for the actual actions and provide the libraries.
Also as I split one of the packages (text) off into a separate project but it still wanted to use library functions from this group.

Some of the code in some places hasn't been fully ported to that way of thinking I guess.

Some refactoring is needed indeed.

dman’s picture

As imagecache processing is a relatively rare event in the lifetime of a website, I was trying not to get all the library processing functions bootstrapped every pageload - so lazy-loading is certainly what we should aim for.

bryancasler’s picture

Just reporting that I'm having this same problem when I'm trying to use "Define Canvas"

Fatal error: Call to undefined function imagecache_rgb_form() in C:\xampp\htdocs\...\sites\all\modules\imagecache_actions\canvasactions\canvasactions.inc on line 60
bryancasler’s picture

Status: Closed (fixed) » Active

*Marking as active*

Bogdan Balan’s picture

Same issue with 7.x-0.0 on Drupal 7.12

Fatal error: Call to undefined function imagecache_rgb_form() in D:\web\countrywidehomes.ca\sites\all\modules\imagecache_actions\canvasactions\canvasactions.inc on line 60
Call Stack
#	Time	Memory	Function	Location
1	0.0001	677200	{main}( )	..\index.php:0
2	0.1485	30346464	menu_execute_active_handler( )	..\index.php:21
3	0.1498	30717960	call_user_func_array ( )	..\menu.inc:517
4	0.1498	30718448	drupal_get_form( )	..\menu.inc:517
5	0.1498	30720904	drupal_build_form( )	..\form.inc:123
6	0.1498	30723512	drupal_retrieve_form( )	..\form.inc:331
7	0.1499	30725072	call_user_func_array ( )	..\form.inc:787
8	0.1499	30725648	image_effect_form( )	..\form.inc:787
9	0.1499	30727656	call_user_func ( )	..\image.admin.inc:393
10	0.1499	30727688	canvasactions_definecanvas_form( )	..\image.admin.inc:393
lastar84’s picture

Same here with 7.x-0.0 on Drupal 7.12

But updated to 7.x-1.x-dev on Drupal 7.12 and did not have this issue.

fietserwin’s picture

Version: 7.x-0.0 » 7.x-1.x-dev
Status: Active » Fixed

It is indeed fixed in 7.x-1.x-dev.

Status: Fixed » Closed (fixed)

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