Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.203
diff -u -p -r1.203 module.inc
--- includes/module.inc	19 Nov 2010 20:35:31 -0000	1.203
+++ includes/module.inc	19 Nov 2010 22:14:58 -0000
@@ -673,9 +673,10 @@ function module_implements($hook, $sort 
  * Retrieve a list of what hooks are explicitly declared.
  */
 function module_hook_info() {
-  $hook_info = &drupal_static(__FUNCTION__, array());
+  $hook_info = &drupal_static(__FUNCTION__);
 
-  if (empty($hook_info)) {
+  if (!isset($hook_info)) {
+    $hook_info = array();
     $cache = cache_get('hook_info', 'cache_bootstrap');
     if ($cache === FALSE) {
       // Rebuild the cache and save it.
@@ -741,10 +742,21 @@ function module_invoke() {
   $module = $args[0];
   $hook = $args[1];
   unset($args[0], $args[1]);
-  if (module_hook($module, $hook)) {
+  $hook_exists = module_hook($module, $hook);
+  // If the hook implementation does not exist, check whether it may live in an
+  // optional include file registered via hook_hook_info().
+  if (!$hook_exists) {
+    $hook_info = module_hook_info();
+    if (isset($hook_info[$hook]['group'])) {
+      module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
+      $hook_exists = module_hook($module, $hook);
+    }
+  }
+  if ($hook_exists) {
     return call_user_func_array($module . '_' . $hook, $args);
   }
 }
+
 /**
  * Invoke a hook in all enabled modules that implement it.
  *
