Browse Source

Fix issue where __debugInfo() would be called with 0 depth.

When the remaining depth is 0, no properties should be extracted and
exported.
mark_story 11 years ago
parent
commit
432881fac4
2 changed files with 2 additions and 6 deletions
  1. 1 1
      src/Utility/Debugger.php
  2. 1 5
      tests/TestCase/Utility/DebuggerTest.php

+ 1 - 1
src/Utility/Debugger.php

@@ -576,7 +576,7 @@ class Debugger {
 		$break = "\n" . str_repeat("\t", $indent);
 		$end = "\n" . str_repeat("\t", $indent - 1);
 
-		if (method_exists($var, '__debugInfo')) {
+		if ($depth > 0 && method_exists($var, '__debugInfo')) {
 			return $out . "\n" .
 				substr(static::_array($var->__debugInfo(), $depth - 1, $indent), 1, -1) .
 				$end . '}';

+ 1 - 5
tests/TestCase/Utility/DebuggerTest.php

@@ -645,11 +645,7 @@ TEXT;
 object(Cake\Test\TestCase\Utility\DebuggableThing) {
 
 	'foo' => 'bar',
-	'inner' => object(Cake\Test\TestCase\Utility\DebuggableThing) {
-
-		[maximum depth reached]
-	
-	}
+	'inner' => object(Cake\Test\TestCase\Utility\DebuggableThing) {}
 
 }
 eos;