Skip to content

Commit

Permalink
Fixed inconsistent debug parameters and empty '(line )'
Browse files Browse the repository at this point in the history
  • Loading branch information
markomarkovic committed Nov 4, 2011
1 parent 926ac32 commit 73429b3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/Cake/basics.php
Expand Up @@ -76,39 +76,47 @@ function debug($var = false, $showHtml = null, $showFrom = true) {
if (Configure::read('debug') > 0) {
$file = '';
$line = '';
$lineInfo = '';
if ($showFrom) {
$calledFrom = debug_backtrace();
$file = substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1);
$line = $calledFrom[0]['line'];
}
$html = <<<HTML
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%s</strong>)</span>
%s
<pre class="cake-debug">
%s
</pre>
</div>
HTML;
$text = <<<TEXT
$text = <<<TEXT
%s (line %s)
%s
########## DEBUG ##########
%s
###########################
TEXT;
$template = $html;
if (php_sapi_name() == 'cli') {
if (php_sapi_name() == 'cli' || $showHtml === false) {
$template = $text;
if ($showFrom) {
$lineInfo = sprintf('%s (line %s)', $file, $line);
}
}
if ($showHtml === null && $template !== $text) {
$showHtml = true;
}
$var = print_r($var, true);
if ($showHtml) {
$template = $html;
$var = h($var);
if ($showFrom) {
$lineInfo = sprintf('<span><strong>%s</strong> (line <strong>%s</strong>)</span>', $file, $line);
}
}
printf($template, $file, $line, $var);
printf($template, $lineInfo, $var);
}
}

Expand Down

0 comments on commit 73429b3

Please sign in to comment.