Hi,

Subjects sounds strange, but let me explain :) This module should be renamed because it interferes with og and og_menu modules.

This module has a hook hook_menu_node_update();
Drupal core has a hook hook_node_update();

og_menu has an implementation of hook_node_update with function name og_menu_node_update(). When module_invoke_all runs on 'menu_node_update', it thinks that that og module implement this hook, but actually, it is og_menu which implements node_update(). All function_exists success because og_menu implements the function name, but the system crashes on entity_extract_ids().

What does the community thinks?

Regards

Comments

agentrickard’s picture

Easier to rename the hook.

rv0’s picture

Priority: Normal » Major

Got burned by this too.

Luckily this module provides a wrapper for the invoke, which means the code only has to change in one place (well, that and the menu_node.api.php file)

in _menu_node_invoke it has:

  module_invoke_all('menu_node_' . $hook, $link, $node);

Some suggestions for changing it:

  module_invoke_all('menu_node_invoke_' . $hook, $link, $node);
  module_invoke_all('menu_node_trigger_' . $hook, $link, $node);

Any other suggestions for a name? Willing to provide a patch if we can agree on a suitable name.

rv0’s picture

Title: This module should be renamed :) » Rename module hooks to avoid conflict with *menu modules implementing hook_node_*

Better title.

rv0’s picture

Status: Active » Needs review
StatusFileSize
new1.49 KB

*Bump

Can't believe I got burned by this again.
Attaching patch this time

Status: Needs review » Needs work

The last submitted patch, 4: 2184289-4-rename_menu_node_module_hooks.patch, failed testing.

rv0’s picture

StatusFileSize
new2.93 KB

didnt see the test module, updated patch

rv0’s picture

Status: Needs work » Needs review
stefan.r’s picture

Patch looks good but it will break custom modules implementing the obsolete hooks. Perhaps we should do a check in hook_requirements() as to whether any other modules implement any of the obsolete hooks and throw a warning if so?

rv0’s picture

Havent written anything like that before. I'm willing to write it the next time I get burned by this issue ;)

cravecode’s picture

Wanted to confirm this patch works for me. Maybe instead of worrying about legacy support, this patch gets rolled into a release with a major release number change and a short release note mentioning the change.

agentrickard’s picture

This module could use a new maintainer to push that through.

Babou’s picture

The patch works for me but I don't like that approach. It can potentially break something on at least 10k websites if they update the module once this is released.

I would rather look at this issue the other way around and check the value received in the hooks implementations done on og_menu.

This issue does not affect all modules ending with menu. It affects og_menu only because og exists and Drupal thinks that the function og_menu_node_insert/update/delete is part of the og module (more info available here #2601170).

rv0’s picture

So you suggest I add stupid checks to OG Menu code which may or may not cause issues while the real issue is poor naming of hooks here?
Well.. OG Menu is clearly outnumbered so I guess I should then :(

Babou’s picture

I agree the checks looks a bit silly, especially in a hook implementation, but I tend to think that it's a good practice to test the values we get as parameters instead of blindly relying on them.

In this case, I find it personnaly less risky to patch og_menu with the aforementioned checks than to change the poolry named hooks in a module containing API in its name :)

Babou’s picture

Or, alternatively, you could write your own module_invoke_all function to filter out the undesired function with a blacklist (exposed as a variable in the GUI).

Which sounds silly as well. Maybe I need some rest.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Let's do this as the menu hooks are core and the conflict there is likely more common.

rv0’s picture

Bump

OG Menu has been updated to 3.1 now, without any fix for this.

rohittiwari’s picture

Hey guys any update on this, which approach is going to be used renaming the hook or module?

vuil’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

  • vuil committed edc6b57 on 7.x-1.x authored by rv0
    Issue #2184289 by rv0, vuil: Rename module hooks to avoid conflict with...
vuil’s picture

vuil’s picture

Status: Patch (to be ported) » Fixed

I close the issue as Fixed.

Status: Fixed » Closed (fixed)

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