From cedc01cd09ffcad748bac344aa1db8586b818c20 Mon Sep 17 00:00:00 2001
From: Axel Rutz <axel.rutz@clever-systems.net>
Date: Sun, 28 Sep 2014 02:24:34 +0200
Subject: [PATCH] =?UTF-8?q?Issue=20#2193481:=C2=A0Backtrace=20causes=20WSOD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 commerce_devel.module |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/commerce_devel.module b/commerce_devel.module
index 2054628..2807822 100644
--- a/commerce_devel.module
+++ b/commerce_devel.module
@@ -237,6 +237,7 @@ function commerce_devel_printable_backtrace($backtrace, $is_exception = FALSE) {
   if (!$is_exception) {
     array_shift($backtrace);
   }
+  $max_string_length = variable_get('commerce_devel_max_string_length', 32);
   // Generate a backtrace containing only scalar argument values.
   $message = '<pre class="backtrace">';
   foreach ($backtrace as $trace) {
@@ -252,8 +253,14 @@ function commerce_devel_printable_backtrace($backtrace, $is_exception = FALSE) {
     }
     if (isset($trace['args'])) {
       foreach ($trace['args'] as $arg) {
-        if (is_scalar($arg)) {
-          $call['args'][] = is_string($arg) ? "'$arg'" : $arg;
+        if (is_string($arg)) {
+          if (strlen($arg) > $max_string_length) {
+            $arg = substr($arg, 0, $max_string_length) . '…';
+          }
+          $call['args'][] = "'$arg'";
+        }
+        elseif (is_scalar($arg)) {
+          $call['args'][] = $arg;
         }
         else {
           $call['args'][] = ucfirst(gettype($arg));
-- 
1.7.9.5

