diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 95ea79f..87206c7 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -209,7 +209,10 @@ function _drupal_log_error($error, $fatal = FALSE) { // Check if verbose error reporting is on. $error_level = _drupal_get_error_level(); - $error_message_format = '%type: @message in %function (line %line of %file).'; + // We call SafeMarkup::format() 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. + $message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error); // With verbose logging, we will append a backtrace. if ($error_level == ERROR_REPORTING_DISPLAY_VERBOSE) { @@ -220,13 +223,9 @@ function _drupal_log_error($error, $fatal = FALSE) { array_shift($backtrace); // Generate a backtrace containing only scalar argument values. $error['@backtrace'] = Error::formatBacktrace($backtrace); - $error_message_format .= '
@backtrace
'; + $message = SafeMarkup::format('%type: @message in %function (line %line of %file).
@backtrace
', $error); } - // We call SafeMarkup::format() 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. - $message = SafeMarkup::format($error_message_format, $error); if (\Drupal::hasService('session')) { // Message display is dependent on sessions being available. diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php index e96a392..1375bc4 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php @@ -107,7 +107,10 @@ protected function onHtml(GetResponseForExceptionEvent $event) { unset($error['backtrace']); - $error_message_format = '%type: @message in %function (line %line of %file).'; + // We call SafeMarkup::format 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. + $message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error); // With verbose logging, we will append a backtrace. if ($this->getErrorLevel() == ERROR_REPORTING_DISPLAY_VERBOSE) { @@ -124,14 +127,9 @@ protected function onHtml(GetResponseForExceptionEvent $event) { // Generate a backtrace containing only scalar argument values. $error['@backtrace'] = Error::formatBacktrace($backtrace); - $error_message_format .= '
@backtrace
'; + $message = SafeMarkup::format('%type: @message in %function (line %line of %file).
@backtrace
', $error); } - // We call SafeMarkup::format 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. - $message = SafeMarkup::format($error_message_format, $error); - // Do not translate the string to avoid errors producing more errors. drupal_set_message($message, $class, TRUE); }