diff --git a/core/includes/errors.inc b/core/includes/errors.inc index c41c688..a486d9e 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -209,12 +209,7 @@ function _drupal_log_error($error, $fatal = FALSE) { // Check if verbose error reporting is on. $error_level = _drupal_get_error_level(); - // With verbose logging, we will append a backtrace. To keep our string - // safe, we need to include the
 tags inside the string to be
-      // formatted, and not included as part of the placeholder.
-      // 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.
+      // With verbose logging, we will append a backtrace.
       if ($error_level == ERROR_REPORTING_DISPLAY_VERBOSE) {
         // First trace is the error itself, already contained in the message.
         // While the second trace is the error source and also contained in the
@@ -223,12 +218,17 @@ function _drupal_log_error($error, $fatal = FALSE) {
         array_shift($backtrace);
         // Generate a backtrace containing only scalar argument values.
         $error['@backtrace'] = Error::formatBacktrace($backtrace);
-        $message = SafeMarkup::format('%type: @message in %function (line %line of %file). 
@backtrace
', $error); + $error_message_format = '%type: @message in %function (line %line of %file).
@backtrace
'; } else { - $message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error); + $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($error_message_format, $error); + if (\Drupal::hasService('session')) { // Message display is dependent on sessions being available. drupal_set_message($message, $class, TRUE); diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php index 7438a81..551b469 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php @@ -109,12 +109,7 @@ protected function onHtml(GetResponseForExceptionEvent $event) { $error_level = _drupal_get_error_level(); unset($error['backtrace']); - // With verbose logging, we will append a backtrace. To keep our string - // safe, we need to include the
 tags inside the string to be
-      // formatted, and not included as part of the placeholder.
-      // 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.
+      // With verbose logging, we will append a backtrace.
       if ($error_level == ERROR_REPORTING_DISPLAY_VERBOSE) {
         $backtrace_exception = $exception;
         while ($backtrace_exception->getPrevious()) {
@@ -128,11 +123,16 @@ protected function onHtml(GetResponseForExceptionEvent $event) {
         array_shift($backtrace);
         // Generate a backtrace containing only scalar argument values.
         $error['@backtrace'] = Error::formatBacktrace($backtrace);
-        $message = SafeMarkup::format('%type: @message in %function (line %line of %file). 
@backtrace
', $error); + $error_message_format = '%type: @message in %function (line %line of %file).
@backtrace
'; } else { - $message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error); + $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($error_message_format, $error); // Do not translate the string to avoid errors producing more errors. drupal_set_message($message, $class, TRUE);