Hi @all,

this just took me three hours to figure out:

I built a module defining an own hook and describing it with hook_hook_info(). Lets say the module name is "mymodule" and the hook's name is "mymoduleapi". This is what my hook_hook_info() would look like:

function mymodule_hook_info() {
  return array(
    'mymodule' => array(
      'mymoduleapi' => array(
        'operation' => array(
          'runs when' => t('Whenever I like'),
        )
      )
    )
  );
}

Unfortunately this does not work and my triggers ar enot shown on admin/build/trigger/mymodule because the module's and the hook's name are different... even though the documentation of hook_hook_info() does not mention any problems with that and even has an example with "node" and "nodeapi". After hours of testing and searching I found the following code in trigger_assign() in trigger.admin.inc:

function trigger_assign($type = NULL) {
  // If no type is specified we default to node actions, since they
  // are the most common.
  if (!isset($type)) {
    drupal_goto('admin/build/trigger/node');
  }
  if ($type == 'node') {
    $type = 'nodeapi';
  }

  $output = '';
  $hooks = module_invoke_all('hook_info');
  foreach ($hooks as $module => $hook) {
    if (isset($hook[$type])) {
      foreach ($hook[$type] as $op => $description) {
	  
        $form_id = 'trigger_'. $type .'_'. $op .'_assign_form';
        $output .= drupal_get_form($form_id, $type, $op, $description['runs when']);
      }
    }
  }
  return $output;
}

As you can see, "node" s a special case where the hook name is rewritten hard-coded and the assigned hook name of hook_hook_info() is not used anymore as only $module and $hook[$type] (where $type is actually the module name passed from hook_menu() in trigger module as far as I see) So right now I am wondering if this is a bug in this function, or if the documentation is not correct or missing some points or just uses a really bad example?!

I'd appreciate if someone might have a look at it.

Thanx in advance & cheers

hctom

Comments

dpearcefl’s picture

Is this still an issue using current Drupal 6?

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.