- Fixed bug #51445 (var_dump() invalid/slow *RECURSION* detection)
authorFelipe Pena <felipe@php.net>
Fri, 2 Apr 2010 21:44:09 +0000 (21:44 +0000)
committerFelipe Pena <felipe@php.net>
Fri, 2 Apr 2010 21:44:09 +0000 (21:44 +0000)
22 files changed:
Zend/tests/bug35163.phpt
Zend/tests/bug35163_2.phpt
Zend/tests/bug35163_3.phpt
Zend/tests/bug35239.phpt
Zend/tests/closure_020.phpt
Zend/tests/closure_034.phpt
Zend/tests/closure_035.phpt
Zend/tests/foreach_002.phpt
Zend/tests/gc_004.phpt
Zend/tests/gc_005.phpt
Zend/tests/gc_006.phpt
Zend/tests/gc_007.phpt
Zend/tests/gc_008.phpt
Zend/tests/gc_009.phpt
Zend/tests/gc_010.phpt
Zend/tests/gc_011.phpt
Zend/tests/objects_020.phpt
ext/standard/tests/array/array_map_variation2.phpt
ext/standard/tests/array/array_push_variation4.phpt
ext/standard/tests/array/array_values_variation4.phpt
ext/standard/tests/array/natcasesort_variation7.phpt
ext/standard/var.c

index 4501fa9372c3cd436c0c6fa79d32675e333b1700..6a10d244ba0953922886ca39ac4e819c79245171 100755 (executable)
@@ -17,22 +17,8 @@ array(1) {
     [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*
   }
 }
index 4adf7709ae716e5fd17ad8b385b8c4a599f9ade0..01387204c82de4a498a4699fbf0c87b1b1574838 100755 (executable)
@@ -20,46 +20,17 @@ 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*
   }
   [2]=>
   &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*
   }
 }
-
index d2b3c25bfe3b20c0ab19187d67160b7378b690d3..6c6a57f2541cd35acd2dfabe8076ee993b53bd07 100755 (executable)
@@ -11,29 +11,15 @@ var_dump($a);
 $a->b = null;
 $a = null;
 ?>
---EXPECT--
-object(stdClass)#1 (1) {
+--EXPECTF--
+object(stdClass)#%d (1) {
   ["b"]=>
   &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*
   }
 }
index 7fc7b7d3b630ea02ed24e248adfbafbaa8535791..869971e2a26b70ddb63d477129aca58bc047f35f 100755 (executable)
@@ -12,30 +12,16 @@ var_dump($a);
 $a->x0->y1 = "ok\n";
 echo $a->x0;
 ?>
---EXPECT--
-object(stdClass)#1 (1) {
+--EXPECTF--
+object(stdClass)#%d (1) {
   ["x0"]=>
-  &object(stdClass)#2 (3) {
+  &object(stdClass)#%d (3) {
     ["y0"]=>
     string(1) "b"
     ["y1"]=>
-    &object(stdClass)#2 (3) {
-      ["y0"]=>
-      string(1) "b"
-      ["y1"]=>
-      *RECURSION*
-      ["y2"]=>
-      *RECURSION*
-    }
+    *RECURSION*
     ["y2"]=>
-    &object(stdClass)#2 (3) {
-      ["y0"]=>
-      string(1) "b"
-      ["y1"]=>
-      *RECURSION*
-      ["y2"]=>
-      *RECURSION*
-    }
+    *RECURSION*
   }
 }
 ok
index 7b4c60b9bdff46ac44b69ab73ded3ca0bc4c6588..9d04a9af54c6381d0e78f1cba9cf9541cc909ca7 100644 (file)
@@ -31,18 +31,7 @@ object(foo)#%d (%d) {
     ["static"]=>
     array(1) {
       ["a"]=>
-      &object(foo)#%d (2) {
-        ["test":"foo":private]=>
-        int(3)
-        ["a"]=>
-        object(Closure)#%d (1) {
-          ["static"]=>
-          array(1) {
-            ["a"]=>
-            *RECURSION*
-          }
-        }
-      }
+      *RECURSION*
     }
   }
 }
index d1356c31dab8bb3996d9813470e08454235cd075..8ba276a68a7a2ce54fd819c151a4ab4b074e37db 100644 (file)
@@ -9,17 +9,11 @@ var_dump($a);
 ?>
 ===DONE===
 --EXPECTF--
-object(Closure)#1 (1) {
+object(Closure)#%d (1) {
   ["static"]=>
   array(1) {
     ["a"]=>
-    &object(Closure)#1 (1) {
-      ["static"]=>
-      array(1) {
-        ["a"]=>
-        *RECURSION*
-      }
-    }
+    *RECURSION*
   }
 }
 ===DONE===
index ac8b4caea088ece5ca4430c60a3e080aa895e73f..e39a991ab6bfb77c8aa4e08919c18ba13ec67741 100644 (file)
@@ -18,14 +18,8 @@ var_dump($x());
 object(Closure)#%d (1) {
   ["static"]=>
   array(1) {
-    [%u|b%"x"]=>
-    &object(Closure)#%d (1) {
-      ["static"]=>
-      array(1) {
-        [%u|b%"x"]=>
-        *RECURSION*
-      }
-    }
+    ["x"]=>
+    *RECURSION*
   }
 }
 int(1)
index 643e6539278631c0e6ee5ccca1cd448c7c403c0a..5523424ce9561523778e9cd1d2604e7d057ecab0 100644 (file)
@@ -15,9 +15,6 @@ array(1) {
   ["a"]=>
   &array(1) {
     ["a"]=>
-    &array(1) {
-      ["a"]=>
-      *RECURSION*
-    }
+    *RECURSION*
   }
 }
index 8ff5bebfb2e673027339ffad27e2548a5b735ec7..1b6f70abe6803a3d14d955dd18d4bebfe6afe683 100644 (file)
@@ -16,10 +16,7 @@ array(1) {
   [0]=>
   &array(1) {
     [0]=>
-    &array(1) {
-      [0]=>
-      *RECURSION*
-    }
+    *RECURSION*
   }
 }
 int(1)
index 97b368fce6ce8d4135ffedb5489634a670d63522..71fb8909f58fe7b013422c46efc4a9916a4f1b47 100644 (file)
@@ -11,13 +11,10 @@ unset($a);
 var_dump(gc_collect_cycles());
 echo "ok\n"
 ?>
---EXPECT--
-object(stdClass)#1 (1) {
+--EXPECTF--
+object(stdClass)#%d (1) {
   ["a"]=>
-  object(stdClass)#1 (1) {
-    ["a"]=>
-    *RECURSION*
-  }
+  *RECURSION*
 }
 int(1)
 ok
index 0b3a91e2f40d2e5e7ca9d5df6b5192f3de57d68e..c633d038f0cda1f0a3b7eb872730a37f8d6fa87b 100644 (file)
@@ -12,18 +12,12 @@ unset($a);
 var_dump(gc_collect_cycles());
 echo "ok\n"
 ?>
---EXPECT--
-object(stdClass)#1 (1) {
+--EXPECTF--
+object(stdClass)#%d (1) {
   ["a"]=>
   array(1) {
     [0]=>
-    &object(stdClass)#1 (1) {
-      ["a"]=>
-      array(1) {
-        [0]=>
-        *RECURSION*
-      }
-    }
+    *RECURSION*
   }
 }
 int(2)
index 1a45ecf1ed732acd0153bbff3301f0c87aaa1e75..8601ea43b15127b43d0ddc03c5d1f2a41ed32749 100644 (file)
@@ -17,10 +17,7 @@ array(1) {
   [0]=>
   &array(1) {
     [0]=>
-    &array(1) {
-      [0]=>
-      *RECURSION*
-    }
+    *RECURSION*
   }
 }
 int(0)
index e27a6b402ca6f96db91aafef5bb28c1bb0355535..289d581d60689f4e09d4c059f8327a99651b75cb 100644 (file)
@@ -13,13 +13,10 @@ unset($a);
 var_dump(gc_collect_cycles());
 echo "ok\n"
 ?>
---EXPECT--
-object(stdClass)#2 (1) {
+--EXPECTF--
+object(stdClass)#%d (1) {
   ["a"]=>
-  object(stdClass)#2 (1) {
-    ["a"]=>
-    *RECURSION*
-  }
+  *RECURSION*
 }
 int(0)
 int(1)
index fe703107ae2738baed8f6b3f4c010b4a9cf00638..263d31f45b9f7dcb489b129a3bf1cb06ea992ef0 100644 (file)
@@ -14,18 +14,12 @@ unset($a);
 var_dump(gc_collect_cycles());
 echo "ok\n"
 ?>
---EXPECT--
-object(stdClass)#1 (1) {
+--EXPECTF--
+object(stdClass)#%d (1) {
   ["a"]=>
   array(1) {
     [0]=>
-    &object(stdClass)#1 (1) {
-      ["a"]=>
-      array(1) {
-        [0]=>
-        *RECURSION*
-      }
-    }
+    *RECURSION*
   }
 }
 int(0)
index d08da356a2d3a57118e45865ec80c2a0e107b6db..af2dda3fe1ee3db62263d0e69735505ead064bd9 100644 (file)
@@ -17,10 +17,7 @@ array(1) {
   [0]=>
   &array(1) {
     [0]=>
-    &array(1) {
-      [0]=>
-      *RECURSION*
-    }
+    *RECURSION*
   }
 }
 int(1)
index bcaf21e4d80ac054b858782710c1dba8253949a1..9c4cc2cc0e570728da55db6a1a2712399283cc7d 100644 (file)
@@ -17,13 +17,10 @@ unset($a);
 var_dump(gc_collect_cycles());
 echo "ok\n"
 ?>
---EXPECT--
-object(Foo)#1 (1) {
+--EXPECTF--
+object(Foo)#%d (1) {
   ["a"]=>
-  object(Foo)#1 (1) {
-    ["a"]=>
-    *RECURSION*
-  }
+  *RECURSION*
 }
 __destruct
 int(1)
index b7c709f320530729e8bdfed4743f83df23878e4a..14e34b91557c3e5bab8a80ad03f2ee2891fd4e15 100644 (file)
@@ -13,18 +13,10 @@ $$test->a->b[] = 2;
 var_dump($$test);
 
 ?>
---EXPECT--
-object(stdClass)#1 (2) {
+--EXPECTF--
+object(stdClass)#%d (2) {
   ["a"]=>
-  &object(stdClass)#1 (2) {
-    ["a"]=>
-    *RECURSION*
-    ["b"]=>
-    array(1) {
-      [0]=>
-      int(2)
-    }
-  }
+  *RECURSION*
   ["b"]=>
   array(1) {
     [0]=>
index e9608438f247c69ae455905b71c6759db71b5239..16561abffc1f7fd5989f3d43ce1a508f37e2020e 100644 (file)
@@ -47,16 +47,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) {
@@ -94,16 +85,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*
       }
     }
   }
@@ -127,16 +109,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) {
@@ -166,16 +139,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*
     }
   }
 }
@@ -195,16 +159,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) {
@@ -240,16 +195,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*
     }
     [1]=>
     &array(4) {
@@ -260,16 +206,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*
     }
   }
 }
index ed339204f433c69155a9b20a3429c23ce3a82e43..f8f89042aa517c8ffa00906c9b2a47114ee86ca8 100644 (file)
@@ -104,28 +104,7 @@ array(10) {
     [8]=>
     &string(1) "z"
     [9]=>
-    &array(10) {
-      [0]=>
-      int(1)
-      [1]=>
-      int(2)
-      [2]=>
-      int(3)
-      [3]=>
-      &string(1) "a"
-      [4]=>
-      &string(1) "b"
-      [5]=>
-      &string(1) "c"
-      [6]=>
-      &string(1) "x"
-      [7]=>
-      &string(1) "y"
-      [8]=>
-      &string(1) "z"
-      [9]=>
-      *RECURSION*
-    }
+    *RECURSION*
   }
 }
 Done
index 25980663e7076adbd061847d3f81d04a8ea740a8..9c35331fddb3747a6a7018310055a89d3e3f0e56 100644 (file)
@@ -93,23 +93,7 @@ array(4) {
       int(3)
     }
     [0]=>
-    &array(4) {
-      ["zero"]=>
-      string(4) "zero"
-      ["un"]=>
-      string(3) "one"
-      ["sub"]=>
-      array(3) {
-        [0]=>
-        int(1)
-        [1]=>
-        int(2)
-        [2]=>
-        int(3)
-      }
-      [0]=>
-      *RECURSION*
-    }
+    *RECURSION*
   }
 }
-Done
\ No newline at end of file
+Done
index c038f7d1c5179b872c79884a976dc862f5d40777..91be7e262fccc09d8edcfe599c318e8a137da986 100644 (file)
@@ -44,18 +44,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)
@@ -75,22 +64,11 @@ 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"
   }
   [2]=>
   string(4) "zero"
 }
-Done
\ No newline at end of file
+Done
index de321060f869a3307b27d9c337e73df1cff03962..7e6f6def949de5cbffd0f39bee24eb6eb46681c8 100644 (file)
@@ -116,8 +116,9 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */
                break;
        case IS_ARRAY:
                myht = Z_ARRVAL_PP(struc);
-               if (myht->nApplyCount > 1) {
+               if (++myht->nApplyCount > 1) {
                        PUTS("*RECURSION*\n");
+                       --myht->nApplyCount;
                        return;
                }
                php_printf("%sarray(%d) {\n", COMMON, zend_hash_num_elements(myht));
@@ -126,8 +127,9 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */
                goto head_done;
        case IS_OBJECT:
                myht = Z_OBJDEBUG_PP(struc, is_temp);
-               if (myht && myht->nApplyCount > 1) {
+               if (myht && ++myht->nApplyCount > 1) {
                        PUTS("*RECURSION*\n");
+                       --myht->nApplyCount;
                        return;
                }
 
@@ -138,6 +140,7 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */
 head_done:
                if (myht) {
                        zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_element_dump_func, 1, level);
+                       --myht->nApplyCount;
                        if (is_temp) {
                                zend_hash_destroy(myht);
                                efree(myht);