Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.231
diff -u -F^f -r1.231 bootstrap.inc
--- includes/bootstrap.inc	11 Oct 2008 04:56:34 -0000	1.231
+++ includes/bootstrap.inc	11 Oct 2008 19:18:39 -0000
@@ -823,9 +823,17 @@ function watchdog($type, $message, $vari
       'timestamp'   => REQUEST_TIME,
     );
 
-    // Call the logging hooks to log/process the message
-    foreach (module_implements('watchdog', TRUE) as $module) {
-      module_invoke($module, 'watchdog', $log_message);
+    if (function_exists('module_implements')) {
+      // Call the logging hooks to log/process the message
+      foreach (module_implements('watchdog', TRUE) as $module) {
+        module_invoke($module, 'watchdog', $log_message);
+      }
+    }
+    else {
+      // This section is for handling errors that happen too early, before module.inc
+      // gets loaded. If that happens, we don't have module_implements() yet, and therefore
+      // Drupal will abort if we call it. So we log stuff to the web server's log.
+      error_log(serialize($log_message));
     }
   }
   $in_error_state = FALSE;
