Skip to content

Commit

Permalink
var_dump(): Don't skip recursion detection on first level
Browse files Browse the repository at this point in the history
This is confusing. The current output doesn't make it clear that
we're in fact recursing to the top-level structure.

Closes phpGH-5171.
  • Loading branch information
nikic committed Feb 12, 2020
1 parent 9e56502 commit ae6f45a
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 164 deletions.
18 changes: 2 additions & 16 deletions Zend/tests/bug35163_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,7 @@ array(3) {
[0]=>
int(2)
[1]=>
&array(3) {
[0]=>
int(2)
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
*RECURSION*
[2]=>
&array(3) {
[0]=>
int(2)
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
*RECURSION*
}
5 changes: 1 addition & 4 deletions Zend/tests/closure_026.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ array(1) {
["this"]=>
object(foo)#%d (1) {
["a"]=>
array(1) {
[0]=>
*RECURSION*
}
*RECURSION*
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions Zend/tests/foreach_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,5 @@ foreach (($a = array('a' => array('a' => &$a))) as $a) {
--EXPECT--
array(1) {
["a"]=>
&array(1) {
["a"]=>
*RECURSION*
}
*RECURSION*
}
5 changes: 1 addition & 4 deletions Zend/tests/gc_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ echo "ok\n"
--EXPECT--
array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
*RECURSION*
}
int(1)
ok
5 changes: 1 addition & 4 deletions Zend/tests/gc_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ echo "ok\n"
--EXPECT--
array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
*RECURSION*
}
int(0)
int(1)
Expand Down
5 changes: 1 addition & 4 deletions Zend/tests/gc_010.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ echo "ok\n"
--EXPECT--
array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
*RECURSION*
}
int(1)
ok
5 changes: 1 addition & 4 deletions ext/json/tests/003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ echo "Done\n";
--EXPECTF--
array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
*RECURSION*
}

bool(false)
Expand Down
13 changes: 1 addition & 12 deletions ext/mbstring/tests/bug66964.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,5 @@ array(5) {
[3]=>
string(21) "日本語テキスト"
[4]=>
&array(5) {
[0]=>
string(21) "日本語テキスト"
[1]=>
string(21) "日本語テキスト"
[2]=>
string(21) "日本語テキスト"
[3]=>
string(21) "日本語テキスト"
[4]=>
*RECURSION*
}
*RECURSION*
}
33 changes: 3 additions & 30 deletions ext/standard/tests/array/array_map_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,7 @@ array(4) {
[0]=>
&string(2) "v1"
[1]=>
&array(4) {
["k1"]=>
&string(2) "v1"
["k2"]=>
string(2) "v2"
[0]=>
&string(2) "v1"
[1]=>
*RECURSION*
}
*RECURSION*
}
array(4) {
["k1"]=>
Expand Down Expand Up @@ -91,16 +82,7 @@ array(4) {
[0]=>
&string(2) "v1"
[1]=>
&array(4) {
["k1"]=>
&string(2) "v1"
["k2"]=>
string(2) "v2"
[0]=>
&string(2) "v1"
[1]=>
*RECURSION*
}
*RECURSION*
}
array(4) {
[0]=>
Expand Down Expand Up @@ -141,16 +123,7 @@ array(4) {
[0]=>
&string(2) "v1"
[1]=>
&array(4) {
["k1"]=>
&string(2) "v1"
["k2"]=>
string(2) "v2"
[0]=>
&string(2) "v1"
[1]=>
*RECURSION*
}
*RECURSION*
}
array(4) {
[0]=>
Expand Down
26 changes: 2 additions & 24 deletions ext/standard/tests/array/natcasesort_variation7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,7 @@ array(5) {
[3]=>
string(1) "2"
[4]=>
&array(5) {
[0]=>
int(1)
[1]=>
float(3)
[2]=>
string(4) "zero"
[3]=>
string(1) "2"
[4]=>
*RECURSION*
}
*RECURSION*
}
bool(true)
array(5) {
Expand All @@ -56,18 +45,7 @@ array(5) {
[1]=>
float(3)
[4]=>
&array(5) {
[0]=>
int(1)
[3]=>
string(1) "2"
[1]=>
float(3)
[4]=>
*RECURSION*
[2]=>
string(4) "zero"
}
*RECURSION*
[2]=>
string(4) "zero"
}
Expand Down
54 changes: 6 additions & 48 deletions ext/standard/tests/serialize/serialization_arrays_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,7 @@ echo "Done";
--- 1 refs container:
array(3) {
[0]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
int(1)
[2]=>
int(1)
}
*RECURSION*
[1]=>
int(1)
[2]=>
Expand Down Expand Up @@ -113,23 +106,9 @@ array(3) {
--- 1,2 ref container:
array(3) {
[0]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
int(1)
}
*RECURSION*
[1]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
int(1)
}
*RECURSION*
[2]=>
int(1)
}
Expand Down Expand Up @@ -185,32 +164,11 @@ array(3) {
--- 1,2,3 ref container:
array(3) {
[0]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
*RECURSION*
[1]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
*RECURSION*
[2]=>
&array(3) {
[0]=>
*RECURSION*
[1]=>
*RECURSION*
[2]=>
*RECURSION*
}
*RECURSION*
}
string(56) "a:3:{i:0;a:3:{i:0;R:2;i:1;R:2;i:2;R:2;}i:1;R:2;i:2;R:2;}"
array(3) {
Expand Down
9 changes: 1 addition & 8 deletions ext/standard/tests/serialize/serialization_arrays_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,7 @@ array(3) {
[0]=>
int(1)
[1]=>
&array(3) {
[0]=>
int(1)
[1]=>
int(1)
[2]=>
*RECURSION*
}
*RECURSION*
}
}
string(74) "a:3:{i:0;i:1;i:1;i:1;i:2;a:2:{i:0;i:1;i:1;a:3:{i:0;i:1;i:1;i:1;i:2;R:4;}}}"
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
break;
case IS_ARRAY:
myht = Z_ARRVAL_P(struc);
if (level > 1 && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) {
if (GC_IS_RECURSIVE(myht)) {
PUTS("*RECURSION*\n");
return;
Expand All @@ -136,7 +136,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, num, key, val) {
php_array_element_dump(val, num, key, level);
} ZEND_HASH_FOREACH_END();
if (level > 1 && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(myht);
}
if (level > 1) {
Expand Down

0 comments on commit ae6f45a

Please sign in to comment.