mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixed inconsistent debug parameters and empty '(line )'
This commit is contained in:
parent
926ac32549
commit
73429b357f
1 changed files with 13 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue