]> granicus.if.org Git - php/commitdiff
fix array_walk_recursive() so it doesn't reuse cached fci between calls
authorAntony Dovgal <tony2001@php.net>
Fri, 3 Dec 2004 17:43:23 +0000 (17:43 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 3 Dec 2004 17:43:23 +0000 (17:43 +0000)
and add test for it

ext/standard/array.c
ext/standard/tests/array/array_walk_recursive.phpt [new file with mode: 0644]

index e3173033484fdcf6b97d685cf99c5f8321a21851..4368f2d91ff51c3789c6fc74680ba369cfc85815 100644 (file)
@@ -1157,6 +1157,8 @@ PHP_FUNCTION(array_walk_recursive)
 
        argc = ZEND_NUM_ARGS();
        old_walk_func_name = BG(array_walk_func_name);
+       BG(array_walk_fci_cache) = empty_fcall_info_cache;
+
        if (argc < 2 || argc > 3 ||
                zend_get_parameters_ex(argc, &array, &BG(array_walk_func_name), &userdata) == FAILURE) {
                BG(array_walk_func_name) = old_walk_func_name;
diff --git a/ext/standard/tests/array/array_walk_recursive.phpt b/ext/standard/tests/array/array_walk_recursive.phpt
new file mode 100644 (file)
index 0000000..c3b37c3
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Test array_walk_recursive()
+--FILE--
+<?php
+function foo($value) {
+       echo $value . " foo\n";
+}
+
+function bar($value) {
+       echo $value . " bar\n";
+}
+
+$arr = array (1,2,3);
+var_dump (array_walk_recursive ($arr, 'foo'));
+var_dump (array_walk_recursive ($arr, 'bar'));
+
+?>
+--EXPECTF--
+1 foo
+2 foo
+3 foo
+bool(true)
+1 bar
+2 bar
+3 bar
+bool(true)