I am going through the Pro Drupal Development Book for version 6.x and VanDyk goes througha n example in the menu system where he creates a module named "menufun" that hooks into _menu_alter() and changes the way a user logs out. (page 80-81)

Specifically, VanDyk's function causes the users to get redirected to drupal.org after they log out.

My question is: what if 2 separate, independent modules hook into _menu_alter() and change the log out function? Which function "wins" or has priority over the other?

Comments

nevets’s picture

By default menu hooks run by the alphabetical order of the module names (there is a weight that can change this). Who wins though depends on the modification and how "smart" the hooks are. While in general the later hook will win, the earlier hook might modify information in such a way the second hook does nothing.

esend7881’s picture

Since Drupal is a big community project, has this posed problems in the past? Two separate modules "fighting" over some functionality?

Is there any system in place for Drupal to catch conflicts?

grobemo’s picture

You might be interested in the Utility module, which (among other things) makes it easy to adjust the weight of various modules, which helps avoid this kind of problem. You might submit a feature request there that the module output a list of modules that are altering the same thing (though it would probably be hard to do more than produce lists of, say, all modules that implement hook_form_alter).

esend7881’s picture

Good to know about that module, thanks.

Maybe when/if my ninja skills get good enough, I can contribute on that front. It feels like an important thing for Drupal's core to address these types of conflicts.