Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.147
diff -u -p -r1.147 module.inc
--- includes/module.inc	10 Jul 2009 04:58:08 -0000	1.147
+++ includes/module.inc	14 Jul 2009 17:46:11 -0000
@@ -351,6 +351,9 @@ function module_hook($module, $hook) {
  *   the implementations are loaded as necessary.
  */
 function module_implements($hook, $sort = FALSE) {
+  if (variable_get('registry_disable', FALSE)) {
+    return module_implements_no_registry($hook, $sort);
+  }
   static $implementations = array(), $sorted_implementations = array(), $loaded = array(), $cached_hooks = 0;
 
   if (defined('MAINTENANCE_MODE')) {
@@ -406,6 +409,33 @@ function module_implements($hook, $sort 
   }
 }
 
+function module_implements_no_registry($hook, $sort = FALSE) {
+  static $implementations;
+
+  if (!isset($implementations[$hook])) {
+    $implementations[$hook] = array();
+    $list = module_list();
+    foreach ($list as $module) {
+      if (module_hook($module, $hook)) {
+        $implementations[$hook][] = $module;
+      }
+    }
+  }
+
+  if ($sort) {
+    sort($implementations[$hook]);
+  }
+
+  // The explicit cast forces a copy to be made. This is needed because
+  // $implementations[$hook] is only a reference to an element of
+  // $implementations and if there are nested foreaches (due to nested node
+  // API calls, for example), they would both manipulate the same array's
+  // references, which causes some modules' hooks not to be called.
+  // See also http://www.zend.com/zend/art/ref-count.php.
+  return (array)$implementations[$hook];
+}
+
+
 /**
  * This is the maintenance version of module_implements for internal use only.
  *
