Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.114
diff -u -r1.114 module.inc
--- includes/module.inc	13 Dec 2007 10:46:43 -0000	1.114
+++ includes/module.inc	21 Dec 2007 00:37:39 -0000
@@ -181,31 +181,34 @@
           if ($dependency_name == '-circular-') {
             continue;
           }
-          // $dependency_name is module B (again, see doxygen).
-          $files[$dependency_name]->info['dependents'][$filename] = $filename;
-          $dependency = $files[$dependency_name];
-          if (isset($dependency->info['dependencies']) && is_array($dependency->info['dependencies'])) {
-            // Let's find possible C modules.
-            foreach ($dependency->info['dependencies'] as $candidate) {
-              if (array_search($candidate, $file->info['dependencies']) === FALSE) {
-                // Is this a circular dependency?
-                if ($candidate == $filename) {
-                  // As a module name can not contain dashes, this makes
-                  // impossible to switch on the module.
-                  $candidate = '-circular-';
-                  // Do not display the message or add -circular- more than once.
-                  if (array_search($candidate, $file->info['dependencies']) !== FALSE) {
-                    continue;
+          
+          if (isset($files[$dependency_name])) { // added
+            // $dependency_name is module B (again, see doxygen).
+            $files[$dependency_name]->info['dependents'][$filename] = $filename;
+            $dependency = $files[$dependency_name];
+            if (isset($dependency->info['dependencies']) && is_array($dependency->info['dependencies'])) {
+              // Let's find possible C modules.
+              foreach ($dependency->info['dependencies'] as $candidate) {
+                if (array_search($candidate, $file->info['dependencies']) === FALSE) {
+                  // Is this a circular dependency?
+                  if ($candidate == $filename) {
+                    // As a module name can not contain dashes, this makes
+                    // impossible to switch on the module.
+                    $candidate = '-circular-';
+                    // Do not display the message or add -circular- more than once.
+                    if (array_search($candidate, $file->info['dependencies']) !== FALSE) {
+                      continue;
+                    }
+                    drupal_set_message(t('%module is part of a circular dependency. This is not supported and you will not be able to switch it on.', array('%module' => $file->info['name'])), 'error');
                   }
-                  drupal_set_message(t('%module is part of a circular dependency. This is not supported and you will not be able to switch it on.', array('%module' => $file->info['name'])), 'error');
-                }
-                else {
-                  // We added a new dependency to module A. The next loop will
-                  // be able to use this as "B module" thus finding even
-                  // deeper dependencies.
-                  $new_dependency = TRUE;
+                  else {
+                    // We added a new dependency to module A. The next loop will
+                    // be able to use this as "B module" thus finding even
+                    // deeper dependencies.
+                    $new_dependency = TRUE;
+                  }
+                  $file->info['dependencies'][] = $candidate;
                 }
-                $file->info['dependencies'][] = $candidate;
               }
             }
           }
