diff -u b/core/includes/bootstrap.inc b/core/includes/bootstrap.inc --- b/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -159,6 +159,17 @@ } /** + * Extends the custom PHP error handling. + */ +function _drupal_php_shutdown_error_handler() { + require_once __DIR__ . '/errors.inc'; + _drupal_php_shutdown_error_handler_real(); +} + +// Set the Drupal custom error handler. (requires config()) +drupal_register_shutdown_function('_drupal_php_shutdown_error_handler'); + +/** * Provides custom PHP exception handling. * * Uncaught exceptions are those not enclosed in a try/catch block. They are @@ -962,17 +973,6 @@ } /** - * Extends the custom PHP error handling. - */ -function _drupal_php_shutdown_error_handler() { - require_once __DIR__ . '/errors.inc'; - _drupal_php_shutdown_error_handler_real(); -} - -// Set the Drupal custom error handler. (requires config()) -drupal_register_shutdown_function('_drupal_php_shutdown_error_handler'); - -/** * Provides custom PHP exception handling. * * Uncaught exceptions are those not enclosed in a try/catch block. They are interdiff impossible; taking evasive action reverted: --- b/core/includes/errors.inc +++ a/core/includes/errors.inc @@ -80,53 +80,6 @@ } /** - * Extends the custom PHP error handling to handle error types that cannot be - * captured by the standard PHP error handler. - */ -function _drupal_php_shutdown_error_handler_real() { - // As defined at http://php.net/manual/en/function.set-error-handler.php - // following error types cannot be handled by the custom defined error handler - // callback. - $error_types = array( - E_ERROR, - E_CORE_ERROR, - E_CORE_WARNING, - E_COMPILE_ERROR, - E_COMPILE_WARNING, - ); - - // Check if an error was thrown and it's one that can only be captured by a - // shutdown function. - if (!($error = error_get_last()) || !in_array($error['type'], $error_types)) { - return; - } - - $error_level = $error['type']; - - $types = drupal_error_levels(); - list($severity_msg, $severity_level) = $types[$error_level]; - - if (!function_exists('filter_xss_admin')) { - require_once __DIR__ . '/common.inc'; - } - - // We treat recoverable errors as fatal. - _drupal_log_error(array( - '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error', - // The standard PHP error handler considers that the error messages - // are HTML. We mimick this behavior here. - '!message' => filter_xss_admin($error['message']), - // The function info is not provided. - '%function' => '', - '%file' => $error['file'], - '%line' => $error['line'], - 'severity_level' => $severity_level, - // There is not useful backtrace in this case. - 'backtrace' => array(), - ), TRUE); -} - -/** * Determines whether an error should be displayed. * * When in maintenance mode or when error_level is ERROR_REPORTING_DISPLAY_ALL, unchanged: --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -17,7 +17,7 @@ * Maps PHP error constants to watchdog severity levels. * * The error constants are documented at - * http://php.net/manual/errorfunc.constants.php + * http://php.net/manual/errorfunc.constants.php. * * @ingroup logging_severity_levels */ @@ -104,6 +104,53 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line) { } /** + * Extends the custom PHP error handling to handle error types that cannot be + * captured by the standard PHP error handler. + */ +function _drupal_php_shutdown_error_handler_real() { + // As defined at http://php.net/manual/en/function.set-error-handler.php + // following error types cannot be handled by the custom defined error handler + // callback. + $error_types = [ + E_ERROR, + E_CORE_ERROR, + E_CORE_WARNING, + E_COMPILE_ERROR, + E_COMPILE_WARNING, + ]; + + // Check if an error was thrown and it's one that can only be captured by a + // shutdown function. + if (!($error = error_get_last()) || !in_array($error['type'], $error_types)) { + return; + } + + $error_level = $error['type']; + + $types = drupal_error_levels(); + [$severity_msg, $severity_level] = $types[$error_level]; + + if (!function_exists('filter_xss_admin')) { + require_once __DIR__ . '/common.inc'; + } + + // We treat recoverable errors as fatal. + _drupal_log_error([ + '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error', + // The standard PHP error handler considers that the error messages + // are HTML. We mimick this behavior here. + '!message' => filter_xss_admin($error['message']), + // The function info is not provided. + '%function' => '', + '%file' => $error['file'], + '%line' => $error['line'], + 'severity_level' => $severity_level, + // There is not useful backtrace in this case. + 'backtrace' => [], + ], TRUE); +} + +/** * Determines whether an error should be displayed. * * When in maintenance mode or when error_level is ERROR_REPORTING_DISPLAY_ALL, @@ -236,7 +283,6 @@ function _drupal_log_error($error, $fatal = FALSE) { if ($error_level != ERROR_REPORTING_DISPLAY_VERBOSE) { // Without verbose logging, use a simple message. - // We use \Drupal\Component\Render\FormattableMarkup directly here, // rather than use t() since we are in the middle of error handling, and // we don't want t() to cause further errors. @@ -244,7 +290,6 @@ function _drupal_log_error($error, $fatal = FALSE) { } else { // With verbose logging, we will also include a backtrace. - // First trace is the error itself, already contained in the message. // While the second trace is the error source and also contained in the // message, the message doesn't contain argument values, so we output it