Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.368
diff -u -r1.368 bootstrap.inc
--- includes/bootstrap.inc 31 Mar 2010 15:36:48 -0000 1.368
+++ includes/bootstrap.inc 1 Apr 2010 13:16:12 -0000
@@ -1847,8 +1847,21 @@
*/
function _drupal_exception_handler($exception) {
require_once DRUPAL_ROOT . '/includes/errors.inc';
- // Log the message to the watchdog and return an error page to the user.
- _drupal_log_error(_drupal_decode_exception($exception), TRUE);
+
+ try {
+ // Log the message to the watchdog and return an error page to the user.
+ _drupal_log_error(_drupal_decode_exception($exception), TRUE);
+ }
+ catch (Exception $exception2) {
+ // Another uncaught exception was thrown while handling the first one.
+ // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown.
+ $error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL);
+ if ($error_level == ERROR_REPORTING_DISPLAY_ALL || (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update')) {
+ print 'Additional uncaught exception thrown while handling exception.
';
+ print 'Original
' . _drupal_render_exception_safe($exception) . '
';
+ print 'Additional
' . _drupal_render_exception_safe($exception2) . '
';
+ }
+ }
}
/**
@@ -2690,12 +2703,13 @@
call_user_func_array($callback['callback'], $callback['arguments']);
}
}
- catch(Exception $exception) {
- require_once DRUPAL_ROOT . '/includes/errors.inc';
- // The theme has already been printed so it doesn't make much sense to use
- // drupal_exception_handler() because that would display the maintenaince
- // page below the usual page. For now, just print the error for debugging.
- // @todo: Improve this.
- print t('%type: %message in %function (line %line of %file).', _drupal_decode_exception($exception));
+ catch (Exception $exception) {
+ // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown.
+ $error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL);
+ if ($error_level == ERROR_REPORTING_DISPLAY_ALL || (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update')) {
+ require_once DRUPAL_ROOT . '/includes/errors.inc';
+ print 'Uncaught exception thrown in shutdown function.
';
+ print _drupal_render_exception_safe($exception) . '
';
+ }
}
}
Index: includes/errors.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/errors.inc,v
retrieving revision 1.2
diff -u -r1.2 errors.inc
--- includes/errors.inc 6 Mar 2010 06:31:24 -0000 1.2
+++ includes/errors.inc 1 Apr 2010 13:16:12 -0000
@@ -87,7 +87,8 @@
*
* @param $exception
* The exception object that was thrown.
- * @return An error in the format expected by _drupal_log_error().
+ * @return
+ * An error in the format expected by _drupal_log_error().
*/
function _drupal_decode_exception($exception) {
$message = $exception->getMessage();
@@ -126,6 +127,18 @@
}
/**
+ * Render an error message for an exception without any possibility of a further exception occuring.
+ *
+ * @param $exception
+ * The exception object that was thrown.
+ * @return
+ * An error message.
+ */
+function _drupal_render_exception_safe($exception) {
+ return strtr('%type: %message in %function (line %line of %file).', _drupal_decode_exception($exception));
+}
+
+/**
* Log a PHP error or exception, display an error page in fatal cases.
*
* @param $error
@@ -163,13 +176,7 @@
$number++;
}
- try {
- watchdog('php', '%type: %message in %function (line %line of %file).', $error, $error['severity_level']);
- }
- catch (Exception $e) {
- // Ignore any additional watchdog exception, as that probably means
- // that the database was not initialized correctly.
- }
+ watchdog('php', '%type: %message in %function (line %line of %file).', $error, $error['severity_level']);
if ($fatal) {
drupal_add_http_header('Status', '500 Service unavailable (with message)');