Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed inconsistent debug parameters and empty '(line )'

  • Loading branch information...
commit 73429b357f06cd76f35d81482dd789b1737fe2b9 1 parent 926ac32
Marko Marković markomarkovic authored
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/Cake/basics.php
18 lib/Cake/basics.php
View
@@ -76,6 +76,7 @@ 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);
@@ -83,32 +84,39 @@ function debug($var = false, $showHtml = null, $showFrom = true) {
}
$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);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.