I'm getting this when I try and enable the ImageAPI module, using latest HEAD checkout from 2 minutes ago. Makes it impossible to install the module. :(

Comments

webchick’s picture

This is happening because the hook_requirements() check is doing:

  if (count(imageapi_get_available_toolkits()) == 0) {

However, imageapi_get_available_toolkits() is defined in imageapi.module, which is not loaded at install time.

drewish’s picture

Status: Active » Needs review
StatusFileSize
new2.14 KB

adding a test for runtime...

drewish’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Status: Needs review » Patch (to be ported)

committed that to HEAD. needs to be backported to 5

waddles’s picture

Awesome, thankyou!

drewish’s picture

jrborba’s picture

TO AVOID HEADACHE!!!

On admin/build/modules, imagecache module, select only ImageAPI and ImageAPIGD2. Select "save configuration" and back again to imagecache module. Select Imagecache and ImagecacheUI. Select "save configuration". Voi lá !!! The message disappears.

Good while module don't be available updated. I'm so confused about patch listed.

Regards.

José Ricardo Borba
Porto Alegre - RS - Brasil

luckysmack’s picture

this works...

But if not using GD2 library but you are using Image magick i still works if you enable before the cach and the UI.

Any news on getting this fixed by chance?

miche’s picture

I tried enabling imageAPI first, as suggested above, but still received the error.

So, I applied the 6.x patch (comment #2) to the 5.x-1.x-dev version of imageapi.install and it worked.

Thank you.

mjlF95’s picture

Could you elaborate on how to apply the patch?

miche’s picture

If you look at the above patch file, there are a bunch of pluses (+) and minus (-) in the left column. This indicates that lines either need to be added or removed.

This patch is quite simple.

Find the function:

if (count(imageapi_get_available_toolkits()) == 0) {
$requirements['imageapi_toolkits'] = array(
'title' => $t('ImageAPI Toolkit'),
'value' => $t('No ImageAPI toolkits available'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('ImageAPI requires a Toolkit such as ImageAPI GD or ImageAPI ImageMagick to function. Goto !modules and enable one of them.', array('!modules' => l('admin/build/modules', 'admin/build/modules'))),
);
}

AND wrap it with if ($phase == 'runtime') { }

Good luck!

mjlF95’s picture

Thanks for the help. I couldn't do quite what you said because I couldn't find that same function. What I ended up doing was this. I looked in all files for something along the lines of "imageapi_get_available_toolkits". In the imageapi.module file I found:

/**
* Return a list of available toolkits.
*
* @return
* An array of the enabled image toolkit modules. The module name is the key
* and the value is a sub-array with the module's 'name' and 'description'.
*/
function imageapi_get_available_toolkits() {
static $toolkits;

if (!isset($toolkits)) {
$toolkits = array();
foreach (module_implements('imageapi_toolkit', true) as $module) {
$info = _module_parse_info_file(drupal_get_path('module', $module) .'/'. $module .'.info');
$toolkits[$module] = array('name' => $info['name'], 'description' => $info['description']);
}
}

return $toolkits;
}

I figured I'd go ahead and try the "wrap it with if ($phase == 'runtime') { }" fix you suggested and it seemed to work. Here is what I ended up with:

function imageapi_get_available_toolkits() {
static $toolkits;
if ($phase == 'runtime') {
if (!isset($toolkits)) {
$toolkits = array();
foreach (module_implements('imageapi_toolkit', true) as $module) {
$info = _module_parse_info_file(drupal_get_path('module', $module) .'/'. $module .'.info');
$toolkits[$module] = array('name' => $info['name'], 'description' => $info['description']);
}
}
}
return $toolkits;
}

SamRose’s picture

Version: 5.x-1.x-dev » 5.x-1.2
Status: Patch (to be ported) » Needs review
StatusFileSize
new1003 bytes

I don't know if this patch is correctly "backported" to D5, but it works with DRUPAL-5--1-3 (not currently an option in issue form ?!?)

drewish’s picture

the indenting on the last patch seems pretty wonky... but can we get some reviews if it actually addresses the issue?

Rob_Feature’s picture

I'm not exactly sure which issue this patch (#12) was trying to address. However, I applied it hoping it would fix my issue, and it did. I was getting a white screen of death after attempting to install imageapi 5.x-1.x-dev and, after the patch, I no longer do. It installed successfully.

dopry’s picture

Status: Needs review » Needs work
HallSL’s picture

Patch in #12 worked for me.

drewish’s picture

Can someone roll one that comes with the comment?:

  // Check this at runtime rather than install time because the order of
  // installation doesn't take dependencies into account. ImageAPI may have
  // been installed by not loaded and if we report a requirement error
  // because we can't find its function or no toolkit is enabled modules that
  // depend on us will still be enabled but will have a missing dependency.
  // Seems like a better idea to let everything get enabled and then inform
  // them of the problem.
  if ($phase == 'runtime') {
    if (count(imageapi_get_available_toolkits()) == 0) {
      $requirements['imageapi_toolkits'] = array(
        'title' => $t('ImageAPI Toolkit'),
        'value' => $t('No ImageAPI toolkits available'),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('ImageAPI requires a Toolkit such as ImageAPI GD or ImageAPI ImageMagick to function. Goto !modules and enable one of them.', array(
'!modules' => l('admin/build/modules', 'admin/build/modules'))),
      );
    }
  }
drewish’s picture

drewish’s picture

Version: 5.x-1.2 » 5.x-1.x-dev
Status: Needs work » Fixed
StatusFileSize
new2.01 KB

Committing the attached to DRUPAL-5.

Status: Fixed » Closed (fixed)

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