Heine

  • Home
  • Drupal
  • About
Home

Lazy loading: hook_hook_info is for hook owners only.

Heine —Tue, 2013/07/30 - 22:38

I've recently seen some recommendations to use hook_hook_info to provide "groups" to core-provided hooks so you can move your module's implementations of those hooks to $module.$group.inc. A poor-mans autoloader if you will.

Beware that such use is not in accordance with the API documentation which states that hook_hook_info should be implemented by modules declaring new hooks for other modules to implement.

In addition, having two modules on your system declaring a group for the same hook will break all use of $group.inc's for that particular hook. This happens regardless of whether the group is identical or not.

To reiterate:
  • DON'T use if all you do is implement hooks.
  • DO use to declare own hooks that can be used in other modules.

NB: In rare cases, a module could implement hook_hook_info_alter to change a hook group, but this is again pretty hacky, for modules could still opt to have hook implementations in their main .module file.

  • Planet Drupal
  • Drupal

Recent posts

  • Teampassword manager's password generator is biased
  • Other vectors for SA-CORE-2014-005?
  • Lazy loading: hook_hook_info is for hook owners only.
  • "Always offline" problem in EA's Origin due to antivirus
  • From bug to exploit - Bakery SSO
more

Security reviews

I provide security reviews of custom code, contributed modules, themes and entire sites via LimoenGroen.

Contact us for a quote.

Follow @ustima

Copyright © 2021 by Heine Deelstra. All rights reserved.

  • Home
  • Drupal
  • About