Module_implements should cache the file path and not TRUE/group value for hooks that specify group in hook_hook_info()

Created on 12 June 2010, about 14 years ago
Updated 23 June 2023, about 1 year ago

So this may be treading back towards the registry, but currently it's impossible for Token module β†’ to easily tell the module hook system that it has the menu, profile, and field implementations for tokens. Currently with module_implements we cache discovered implementations like this:

$implementations[hook][module] = FALSE; // Means the hook is located in the module file. Since all module files are loaded on full bootstrap, we don't care where the hook is located.
$implementations[hook][module] = 'group' // Means the hook is located in module.group.inc inside the module's root directory. This group values is taken from hook_hook_info().

Now if we stored the actual file location instead of 'group', it could allow modules to easily add core module support for hooks. In the case of token.module, we'd want to do something like this:

function token_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'tokens' || $hook == 'token_info') {
    $modules = array('menu', 'profile', 'field');
    foreach ($modules as $module) {
      if (module_exists($module) && $file = module_load_include('inc', 'token', $module . '.tokens')) {
        $implementations[$module] = $file;
        // Ensure this gets cached since we made changes.
        $implementations['#write_cache'] = TRUE;
      }
    }
  }
}
✨ Feature request
Status

Closed: duplicate

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 3 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States Dave Reid Nebraska πŸ‡ΊπŸ‡Έ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024