summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-04-03 03:36:11 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-04-03 03:36:11 +0000
commit1e25da7eab1cc9ca572cfbab56b50e342558d631 (patch)
tree31e84f469646242eda85e4a309af4344e2c7d269 /includes
parent807704e1d1a22e50f59c478ddcc5051d68eca48f (diff)
downloadbrdo-1e25da7eab1cc9ca572cfbab56b50e342558d631.tar.gz
brdo-1e25da7eab1cc9ca572cfbab56b50e342558d631.tar.bz2
#742246 by jbrown: Fixed Uncaught exceptions thrown in the exception handler prevent error reporting.
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc32
-rw-r--r--includes/errors.inc23
2 files changed, 38 insertions, 17 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 8d6dae5bf..ebb476f8d 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -1847,8 +1847,21 @@ function _drupal_error_handler($error_level, $message, $filename, $line, $contex
*/
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.<br /><br />';
+ print '<b>Original</b><br />' . _drupal_render_exception_safe($exception) . '<br /><br />';
+ print '<b>Additional</b><br />' . _drupal_render_exception_safe($exception2) . '<br /><br />';
+ }
+ }
}
/**
@@ -2690,12 +2703,13 @@ function _drupal_shutdown_function() {
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.<br /><br />';
+ print _drupal_render_exception_safe($exception) . '<br /><br />';
+ }
}
}
diff --git a/includes/errors.inc b/includes/errors.inc
index 4ed7115e4..c82252cbc 100644
--- a/includes/errors.inc
+++ b/includes/errors.inc
@@ -87,7 +87,8 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
*
* @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 @@ function _drupal_decode_exception($exception) {
}
/**
+ * 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 @@ function _drupal_log_error($error, $fatal = FALSE) {
$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)');