From 5137e0fd294863fd7bbce9e6023be6089130091e Mon Sep 17 00:00:00 2001
From: Alexander Benjamin <alx_benjamin@yahoo.com>
Date: Mon, 10 Aug 2015 16:01:53 +0200
Subject: [PATCH] - Issue #2548787: Fixed debug() message display

---
 core/includes/errors.inc | 52 ++++++++++++++++++++++++------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 99cab85..17e7d94 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -223,38 +223,38 @@ function _drupal_log_error($error, $fatal = FALSE) {
         // Generate a backtrace containing only scalar argument values.
         $message .= '<pre class="backtrace">' . Error::formatBacktrace($backtrace) . '</pre>';
       }
-    }
 
-    if ($fatal) {
-      // We fallback to a maintenance page at this point, because the page generation
-      // itself can generate errors.
-      // Should not translate the string to avoid errors producing more errors.
-      $message = 'The website encountered an unexpected error. Please try again later.' . '<br />' . $message;
+      if ($fatal) {
+        // We fallback to a maintenance page at this point, because the page generation
+        // itself can generate errors.
+        // Should not translate the string to avoid errors producing more errors.
+        $message = 'The website encountered an unexpected error. Please try again later.' . '<br />' . $message;
 
-      if ($is_installer) {
-        // install_display_output() prints the output and ends script execution.
-        $output = array(
-          '#title' => 'Error',
-          '#markup' => $message,
-        );
-        install_display_output($output, $GLOBALS['install_state'], $response->headers->all());
-        exit;
-      }
+        if ($is_installer) {
+          // install_display_output() prints the output and ends script execution.
+          $output = array(
+            '#title' => 'Error',
+            '#markup' => $message,
+          );
+          install_display_output($output, $GLOBALS['install_state'], $response->headers->all());
+          exit;
+        }
 
-      $response->setContent($message);
-      $response->setStatusCode(500, '500 Service unavailable (with message)');
+        $response->setContent($message);
+        $response->setStatusCode(500, '500 Service unavailable (with message)');
 
-      $response->send();
-      // An exception must halt script execution.
-      exit;
-    }
-    else {
-      if (\Drupal::hasService('session')) {
-        // Message display is dependent on sessions being available.
-        drupal_set_message(SafeMarkup::set($message), $class, TRUE);
+        $response->send();
+        // An exception must halt script execution.
+        exit;
       }
       else {
-        print $message;
+        if (\Drupal::hasService('session')) {
+          // Message display is dependent on sessions being available.
+          drupal_set_message(SafeMarkup::set($message), $class, TRUE);
+        }
+        else {
+          print $message;
+        }
       }
     }
   }
-- 
1.9.1

