mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Updating Debugger references
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5508 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
0d1d5f51fa
commit
8c8d0c1088
2 changed files with 75 additions and 24 deletions
|
@ -70,10 +70,6 @@ class Debugger extends Object {
|
||||||
if (!defined('E_RECOVERABLE_ERROR')) {
|
if (!defined('E_RECOVERABLE_ERROR')) {
|
||||||
define('E_RECOVERABLE_ERROR', 4096);
|
define('E_RECOVERABLE_ERROR', 4096);
|
||||||
}
|
}
|
||||||
if (Configure::read() > 0) {
|
|
||||||
Configure::version(); // Make sure the core config is loaded
|
|
||||||
$this->helpPath = Configure::read('Cake.Debugger.HelpPath');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets a reference to the Debugger object instance
|
* Gets a reference to the Debugger object instance
|
||||||
|
@ -85,7 +81,11 @@ class Debugger extends Object {
|
||||||
static $instance = array();
|
static $instance = array();
|
||||||
|
|
||||||
if (!isset($instance[0]) || !$instance[0]) {
|
if (!isset($instance[0]) || !$instance[0]) {
|
||||||
$instance[0] = &new Debugger();
|
$instance[0] =& new Debugger();
|
||||||
|
if (Configure::read() > 0) {
|
||||||
|
Configure::version(); // Make sure the core config is loaded
|
||||||
|
$instance[0]->helpPath = Configure::read('Cake.Debugger.HelpPath');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $instance[0];
|
return $instance[0];
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ class Debugger extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function handleError($code, $description, $file = null, $line = null, $context = null) {
|
function handleError($code, $description, $file = null, $line = null, $context = null) {
|
||||||
|
$_this = Debugger::getInstance();
|
||||||
if (error_reporting() == 0) {
|
if (error_reporting() == 0) {
|
||||||
// Error suppression (@) enabled
|
// Error suppression (@) enabled
|
||||||
return;
|
return;
|
||||||
|
@ -112,11 +113,11 @@ class Debugger extends Object {
|
||||||
if (empty($line)) {
|
if (empty($line)) {
|
||||||
$line = '??';
|
$line = '??';
|
||||||
}
|
}
|
||||||
$file = $this->trimPath($file);
|
$file = $_this->trimPath($file);
|
||||||
|
|
||||||
$info = compact('code', 'description', 'file', 'line');
|
$info = compact('code', 'description', 'file', 'line');
|
||||||
if (!in_array($info, $this->errors)) {
|
if (!in_array($info, $_this->errors)) {
|
||||||
$this->errors[] = $info;
|
$_this->errors[] = $info;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -147,46 +148,46 @@ class Debugger extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
$helpCode = null;
|
$helpCode = null;
|
||||||
if (!empty($this->helpPath) && preg_match('/.*\[([0-9]+)\]$/', $description, $codes)) {
|
if (!empty($_this->helpPath) && preg_match('/.*\[([0-9]+)\]$/', $description, $codes)) {
|
||||||
if (isset($codes[1])) {
|
if (isset($codes[1])) {
|
||||||
$helpCode = $codes[1];
|
$helpCode = $codes[1];
|
||||||
$description = trim(preg_replace('/\[[0-9]+\]$/', '', $description));
|
$description = trim(preg_replace('/\[[0-9]+\]$/', '', $description));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = "document.getElementById(\"CakeStackTrace" . count($this->errors) . "\").style.display = (document.getElementById(\"CakeStackTrace" . count($this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
|
$link = "document.getElementById(\"CakeStackTrace" . count($_this->errors) . "\").style.display = (document.getElementById(\"CakeStackTrace" . count($_this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
|
||||||
$out = "<a href='javascript:void(0);' onclick='{$link}'><b>{$error}</b> ({$code})</a>: {$description} [<b>{$file}</b>, line <b>{$line}</b>]";
|
$out = "<a href='javascript:void(0);' onclick='{$link}'><b>{$error}</b> ({$code})</a>: {$description} [<b>{$file}</b>, line <b>{$line}</b>]";
|
||||||
|
|
||||||
if (Configure::read() > 0) {
|
if (Configure::read() > 0) {
|
||||||
debug($out);
|
debug($out);
|
||||||
e('<div id="CakeStackTrace' . count($this->errors) . '" class="cake-stack-trace" style="display: none;">');
|
e('<div id="CakeStackTrace' . count($_this->errors) . '" class="cake-stack-trace" style="display: none;">');
|
||||||
if (!empty($context)) {
|
if (!empty($context)) {
|
||||||
$link = "document.getElementById(\"CakeErrorContext" . count($this->errors) . "\").style.display = (document.getElementById(\"CakeErrorContext" . count($this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
|
$link = "document.getElementById(\"CakeErrorContext" . count($_this->errors) . "\").style.display = (document.getElementById(\"CakeErrorContext" . count($_this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
|
||||||
e("<a href='javascript:void(0);' onclick='{$link}'>Context</a> | ");
|
e("<a href='javascript:void(0);' onclick='{$link}'>Context</a> | ");
|
||||||
$link = "document.getElementById(\"CakeErrorCode" . count($this->errors) . "\").style.display = (document.getElementById(\"CakeErrorCode" . count($this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
|
$link = "document.getElementById(\"CakeErrorCode" . count($_this->errors) . "\").style.display = (document.getElementById(\"CakeErrorCode" . count($_this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
|
||||||
e("<a href='javascript:void(0);' onclick='{$link}'>Code</a>");
|
e("<a href='javascript:void(0);' onclick='{$link}'>Code</a>");
|
||||||
|
|
||||||
if (!empty($helpCode)) {
|
if (!empty($helpCode)) {
|
||||||
e(" | <a href='{$this->helpPath}{$helpCode}' target='blank'>Help</a>");
|
e(" | <a href='{$_this->helpPath}{$helpCode}' target='blank'>Help</a>");
|
||||||
}
|
}
|
||||||
|
|
||||||
e("<pre id=\"CakeErrorContext" . count($this->errors) . "\" class=\"cake-context\" style=\"display: none;\">");
|
e("<pre id=\"CakeErrorContext" . count($_this->errors) . "\" class=\"cake-context\" style=\"display: none;\">");
|
||||||
foreach ($context as $var => $value) {
|
foreach ($context as $var => $value) {
|
||||||
e("\${$var}\t=\t" . $this->exportVar($value, 1) . "\n");
|
e("\${$var}\t=\t" . $_this->exportVar($value, 1) . "\n");
|
||||||
}
|
}
|
||||||
e("</pre>");
|
e("</pre>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = $this->trace(array('start' => 1, 'format' => 'points'));
|
$files = $_this->trace(array('start' => 1, 'format' => 'points'));
|
||||||
$listing = Debugger::excerpt($files[0]['file'], $files[0]['line'] - 1, 2);
|
$listing = Debugger::excerpt($files[0]['file'], $files[0]['line'] - 1, 2);
|
||||||
|
|
||||||
if (Configure::read() > 0) {
|
if (Configure::read() > 0) {
|
||||||
e("<div id=\"CakeErrorCode" . count($this->errors) . "\" class=\"cake-code-dump\" style=\"display: none;\">");
|
e("<div id=\"CakeErrorCode" . count($_this->errors) . "\" class=\"cake-code-dump\" style=\"display: none;\">");
|
||||||
pr(implode("\n", $listing));
|
pr(implode("\n", $listing));
|
||||||
e('</div>');
|
e('</div>');
|
||||||
|
|
||||||
pr($this->trace(array('start' => 1)));
|
pr($_this->trace(array('start' => 1)));
|
||||||
e('</div>');
|
e('</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,9 +341,11 @@ class Debugger extends Object {
|
||||||
case 'string':
|
case 'string':
|
||||||
return '"' . $var . '"';
|
return '"' . $var . '"';
|
||||||
break;
|
break;
|
||||||
|
case 'object':
|
||||||
|
$var = get_object_vars($var);
|
||||||
case 'array':
|
case 'array':
|
||||||
$out = 'array(';
|
$out = 'array(';
|
||||||
if ($recursion != 0) {
|
if ($recursion !== 0) {
|
||||||
$vars = array();
|
$vars = array();
|
||||||
foreach ($var as $key => $val) {
|
foreach ($var as $key => $val) {
|
||||||
$vars[] = Debugger::exportVar($key) . ' => ' . Debugger::exportVar($val, $recursion - 1);
|
$vars[] = Debugger::exportVar($key) . ' => ' . Debugger::exportVar($val, $recursion - 1);
|
||||||
|
@ -355,14 +358,62 @@ class Debugger extends Object {
|
||||||
case 'resource':
|
case 'resource':
|
||||||
return low(gettype($var));
|
return low(gettype($var));
|
||||||
break;
|
break;
|
||||||
case 'object':
|
|
||||||
return get_class($var) . ' object';
|
|
||||||
break;
|
|
||||||
case 'null':
|
case 'null':
|
||||||
return 'null';
|
return 'null';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function __object($var) {
|
||||||
|
static $history = array();
|
||||||
|
$serialized = serialize($var);
|
||||||
|
array_push($history, $serialized);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
if(is_object($var)) {
|
||||||
|
$className = get_class($var);
|
||||||
|
$objectVars = get_object_vars($var);
|
||||||
|
foreach($objectVars as $key => $value) {
|
||||||
|
$value = ife((!is_object($value) && !is_array($value) && trim($value) == ""), "[empty string]", $value);
|
||||||
|
if(strpos($key, '_', 0) !== 0) {
|
||||||
|
echo "$className::$key = ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_object($value) || is_array($value)) {
|
||||||
|
$serialized = serialize($value);
|
||||||
|
|
||||||
|
if(in_array($serialized, $history, true)) {
|
||||||
|
$value = ife(is_object($value), "*RECURSION* -> " . get_class($value), "*RECURSION*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array(gettype($value), array('boolean', 'integer', 'double', 'string', 'array', 'resource', 'object', 'null'))) {
|
||||||
|
if(is_array($value)) {
|
||||||
|
foreach($value as $name => $output) {
|
||||||
|
if(is_numeric($name)) {
|
||||||
|
echo "$output ";
|
||||||
|
} else {
|
||||||
|
echo "$name => $output ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "\n";
|
||||||
|
} else {
|
||||||
|
echo Debugger::exportVar($value) . "\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo $value . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$objectMethods = get_class_methods($className);
|
||||||
|
foreach($objectMethods as $key => $value) {
|
||||||
|
if(strpos($value, '_', 0) !== 0) {
|
||||||
|
echo "$className::$value() \n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array_pop($history);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Verify that the application's salt has been changed from the default value
|
* Verify that the application's salt has been changed from the default value
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,6 +27,6 @@
|
||||||
<div id="cakeControllerDump">
|
<div id="cakeControllerDump">
|
||||||
<h2><?php __('Controller dump:'); ?></h2>
|
<h2><?php __('Controller dump:'); ?></h2>
|
||||||
<pre>
|
<pre>
|
||||||
<?php print_r($this->controller); ?>
|
<?php Debugger::exportVar($controller); ?>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
Loading…
Add table
Reference in a new issue