diff --git a/core/Debug.php b/core/Debug.php
index a8e6a7757..703f416c0 100644
--- a/core/Debug.php
+++ b/core/Debug.php
@@ -48,26 +48,34 @@ class Debug {
}
static function text($val) {
- if(is_object($val) && $val->hasMethod('debug')) {
- return $val->debug();
- } else {
- if(is_array($val)) {
- $result = "
\n";
- foreach($val as $k => $v) {
- $result .= "- $k = " . Debug::text($v) . "
\n";
- }
- $val = $result . "
\n";
-
- } else if (is_object($val)) {
- $val = var_export($val, true);
+ if(is_object($val)) {
+ if(method_exists($val, 'hasMethod')) {
+ $hasDebugMethod = $val->hasMethod('debug');
} else {
- if(true || !Director::is_ajax()) {
- $val = "" . htmlentities($val) . "
\n";
- }
+ $hasDebugMethod = method_exists($val, 'debug');
+ }
+
+ if($hasDebugMethod) {
+ return $val->debug();
}
-
- return $val;
}
+
+ if(is_array($val)) {
+ $result = "\n";
+ foreach($val as $k => $v) {
+ $result .= "- $k = " . Debug::text($v) . "
\n";
+ }
+ $val = $result . "
\n";
+
+ } else if (is_object($val)) {
+ $val = var_export($val, true);
+ } else {
+ if(true || !Director::is_ajax()) {
+ $val = "" . htmlentities($val) . "
\n";
+ }
+ }
+
+ return $val;
}
/**
@@ -144,6 +152,7 @@ class Debug {
echo "FATAL ERROR: $errstr
\n At line $errline in $errfile
\n
\n
\n";
Debug::backtrace();
+ //Debug::show(debug_backtrace());
echo "Context
\n";
Debug::show($errcontext);
@@ -240,7 +249,7 @@ class Debug {
while( $bt && in_array(self::full_func_name($bt[0]), $ignoredFunctions) ) {
array_shift($bt);
}
-
+
$result = "";
foreach($bt as $item) {
if(Director::is_ajax() && !$ignoreAjax) {
@@ -254,6 +263,8 @@ class Debug {
}
}
+ $result .= 'hi';
+ echo $result;
if($returnVal) return $result;
else echo $result;
}
@@ -268,7 +279,16 @@ class Debug {
if(isset($item['function'])) $funcName .= $item['function'];
if($showArgs && isset($item['args'])) {
- @$funcName .= "(" . implode(",", (array)$item['args']) .")";
+ $args = array();
+ foreach($item['args'] as $arg) {
+ if(!is_object($arg) || method_exists($arg, '__toString')) {
+ $args[] = (string) $arg;
+ } else {
+ $args[] = get_class($arg);
+ }
+ }
+
+ $funcName .= "(" . implode(",", $args) .")";
}
return $funcName;
diff --git a/tests/SapphireTest.php b/tests/SapphireTest.php
index bd6a3380d..17077b240 100644
--- a/tests/SapphireTest.php
+++ b/tests/SapphireTest.php
@@ -167,4 +167,4 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
class SapphireTest extends Object {}
}
-?>
\ No newline at end of file
+?>