diff --git a/includes/module.inc b/includes/module.inc index 89f67c9..5a04382 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -730,8 +730,6 @@ function module_implements($hook, $sort = FALSE, $reset = FALSE) { else { $implementations = $implementations->data; } - // The cache may contain some implementations that are not defined, or that - // require an additional file to be included. } if (!isset($implementations[$hook])) { @@ -755,16 +753,20 @@ function module_implements($hook, $sort = FALSE, $reset = FALSE) { if ($hook != 'module_implements_alter') { drupal_alter('module_implements', $implementations[$hook], $hook); } - // hook_module_implements_alter() may have changed the $group of some hooks, - // or added implementations that are not defined. } + // The first time a hook is used in a request, the implementations must be + // "verified" with function_exists(), and the file specified by $group must be + // included. + // This applies both to implementations loaded from cache, and implementations + // that were discovered just now and may have been changed with + // hook_module_implements_alter(). if (empty($verified[$hook])) { foreach ($implementations[$hook] as $module => $group) { // If this hook implementation is stored in a lazy-loaded file, so include // that file first. if ($group) { - module_load_include($group . '.inc', $module); + module_load_include('inc', $module, "$module.$group"); } // It is possible that a module removed a hook implementation without the // implementations cache being rebuilt yet, so we check whether the