From d2e3af498517d0e459be3b0c66d9c1cad0c6c25a Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Tue, 16 Oct 2012 14:51:53 +0000 Subject: conserve mem in it::error --- it.class | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index f3ef89a..12a35a4 100644 --- a/it.class +++ b/it.class @@ -206,21 +206,18 @@ static function error($p = array(), $body = null, $to = null) # $body and $to de if (!$p['omitdebuginfo']) { - $locals = print_r(array_diff_key((array)$p['locals'], array("GLOBALS", "_GET", "_POST", "_COOKIE")), true); - - if ($trace && ($fulltrace = array_slice(debug_backtrace(), $p['backtraceskip']))) - while (strlen(print_r($fulltrace, true)) > 100000) - array_pop($fulltrace); + foreach (($trace ? debug_backtrace() : array()) as $level => $stackframe) + if ($level >= $p['backtraceskip'] && $tracesize < 100000 && ($tracesize += strlen(print_r($stackframe, true))) < 100000) # save mem + $stackframes[] = $stackframe; $body .= "Host: " . getenv('HOSTNAME') . "\n\n"; - $body .= $locals && strlen($locals) < 100000 ? "Locals: $locals\n\n" : ""; $body .= $p['id'] ? "Filter: graceperiod={$p['graceperiod']} timewindow={$p['timewindow']}\n\n" : ""; $body .= "Time: " . it::date() . "\n\n"; $body .= $_GET ? "\$_GET: " . var_export($_GET, true) . "\n\n" : ""; $body .= $_POST ? "\$_POST: " . var_export($_POST, true) . "\n\n" : ""; $body .= $_COOKIE ? "\$_COOKIE: " . var_export($_COOKIE, true) . "\n\n" : ""; $body .= $_SERVER ? "\$_SERVER: " . var_export($_SERVER, true) . "\n\n" : ""; - $body .= $fulltrace ? "Stack: " . print_r($fulltrace, true) . "\n\n" : ""; + $body .= $stackframes ? "Stack: " . print_r($stackframes, true) . "\n\n" : ""; $body = it::replace(array('(pw|passw|password|secret)\] => .*' => '$1] => ********'), $body, array('utf8' => false)); } -- cgit v1.2.3