summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2004-12-03 17:43:23 +0000
committerAntony Dovgal <tony2001@php.net>2004-12-03 17:43:23 +0000
commitb6b8bf00108703bea2ef0476f53493c77c05f488 (patch)
tree3e0bc7ec1f8f21a980487b06d5c5873ade79d811 /ext/standard
parent9a18fb197de525d83bfdd592e6549dbf35358819 (diff)
downloadphp-git-b6b8bf00108703bea2ef0476f53493c77c05f488.tar.gz
fix array_walk_recursive() so it doesn't reuse cached fci between calls
and add test for it
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/array.c2
-rw-r--r--ext/standard/tests/array/array_walk_recursive.phpt26
2 files changed, 28 insertions, 0 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index e317303348..4368f2d91f 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -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
index 0000000000..c3b37c321c
--- /dev/null
+++ b/ext/standard/tests/array/array_walk_recursive.phpt
@@ -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)