felipe          Wed Jul  8 18:23:08 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/standard/tests/array   bug48854.phpt 

  Modified files:              
    /php-src/ext/standard       array.c 
    /php-src    NEWS 
  Log:
  - MFH: Fixed bug #48854 (array_merge_recursive modifies arrays after first 
one)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.56&r2=1.308.2.21.2.37.2.57&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.56 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.57
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.56   Fri May 15 17:03:03 2009
+++ php-src/ext/standard/array.c        Wed Jul  8 18:23:07 2009
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.56 2009/05/15 17:03:03 moriyoshi Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.57 2009/07/08 18:23:07 felipe Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -2305,6 +2305,7 @@
        array_init_size(return_value, init_size);
 
        for (i = 0; i < argc; i++) {
+               SEPARATE_ZVAL(args[i]);
                if (!replace) {
                        php_array_merge(Z_ARRVAL_P(return_value), 
Z_ARRVAL_PP(args[i]), recursive TSRMLS_CC);
                } else if (recursive && i > 0) { /* First array will be copied 
directly instead */
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.671&r2=1.2027.2.547.2.965.2.672&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.671 
php-src/NEWS:1.2027.2.547.2.965.2.672
--- php-src/NEWS:1.2027.2.547.2.965.2.671       Wed Jul  8 03:06:59 2009
+++ php-src/NEWS        Wed Jul  8 18:23:08 2009
@@ -4,6 +4,8 @@
 - Fixed spl_autoload_unregister/spl_autoad_functions wrt. Closures and
   Functors. (Christian Seiler)
 
+- Fixed bug #48854 (array_merge_recursive modifies arrays after first one).
+  (Felipe)
 - Fixed bug #48788 (RecursiveDirectoryIterator doesn't descend into symlinked
   directories). (Ilia)
 - Fixed bug #48771 (rename() between volumes fails and reports no error on 

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug48854.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/bug48854.phpt
+++ php-src/ext/standard/tests/array/bug48854.phpt
--TEST--
Bug #48854 (array_merge_recursive modifies arrays after first one)
--FILE--
<?php

$array1 = array(
       'friends' => 5,
       'children' => array(
               'dogs' => 0,
       ),
);

$array2 = array(
       'friends' => 10,
       'children' => array(
               'cats' => 5,
       ),
);

$merged = array_merge_recursive($array1, $array2);

var_dump($array1, $array2);

?>
--EXPECTF--
array(2) {
  [%u|b%"friends"]=>
  int(5)
  [%u|b%"children"]=>
  array(1) {
    [%u|b%"dogs"]=>
    int(0)
  }
}
array(2) {
  [%u|b%"friends"]=>
  int(10)
  [%u|b%"children"]=>
  array(1) {
    [%u|b%"cats"]=>
    int(5)
  }
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to