cvs: php-src /ext/standard/tests/array bug34982.phpt
| From: | Dmitry Stogov | Date: | Fri, 28 Oct 2005 10:06:54 +0000 |
| Subject: | cvs: php-src /ext/standard/tests/array bug34982.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-34845@lists.php.net to get a copy of this message | ||
dmitry Fri Oct 28 06:06:54 2005 EDT
Modified files:
/php-src/ext/standard/tests/array bug34982.phpt
Log:
Fixed bug #34982 (array_walk_recursive() modifies elements outside function scope)
http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/bug34982.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/standard/tests/array/bug34982.phpt
diff -u /dev/null php-src/ext/standard/tests/array/bug34982.phpt:1.2
--- /dev/null Fri Oct 28 06:06:54 2005
+++ php-src/ext/standard/tests/array/bug34982.phpt Fri Oct 28 06:06:53 2005
@@ -0,0 +1,40 @@
+--TEST--
+Bug #34982 array_walk_recursive() modifies elements outside function scope
+--FILE--
+<?php
+$ar = array(
+ 'element 1',
+ array('subelement1')
+ );
+
+func($ar);
+print_r($ar);
+
+function func($a) {
+ array_walk_recursive($a, 'apply');
+ print_r($a);
+}
+
+function apply(&$input, $key) {
+ $input = 'changed';
+}
+?>
+--EXPECT--
+Array
+(
+ [0] => changed
+ [1] => Array
+ (
+ [0] => changed
+ )
+
+)
+Array
+(
+ [0] => element 1
+ [1] => Array
+ (
+ [0] => subelement1
+ )
+
+)