]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #43559 (array_merge_recursive() doesn't behave as expected with duplic...
authorFelipe Pena <felipe@php.net>
Wed, 27 Feb 2008 02:04:09 +0000 (02:04 +0000)
committerFelipe Pena <felipe@php.net>
Wed, 27 Feb 2008 02:04:09 +0000 (02:04 +0000)
NEWS
ext/standard/array.c
ext/standard/tests/array/array_merge_recursive_variation5.phpt

diff --git a/NEWS b/NEWS
index 4968482b7b4fd59edd2373ba8b5f23cf14dd13b3..3305e03bd36adabd43aea746925746b0ca8fb735 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -79,6 +79,8 @@ PHP                                                                        NEWS
 - Fixed bug #43589 (a possible infinite loop in bz2_filter.c). (Greg)
 - Fixed bug #43580 (removed bogus declaration of a non-existent php_is_url()
   function). (Ilia)
+- Fixed bug #43559 (array_merge_recursive() doesn't behave as expected with
+  duplicate NULL values). (Felipe, Tony)
 - Fixed bug #43533 (escapeshellarg('') returns null). (Ilia)
 - Fixed bug #43527 (DateTime created from a timestamp reports environment
   timezone). (Derick)
index 98666f3cfaea4fc06cb3e3494cb543c89c2bb7d4..2dbfa0e0358b1dae2fde0eacf2f48e59f4a99d4c 100644 (file)
@@ -2312,8 +2312,18 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
                                        SEPARATE_ZVAL(dest_entry);
                                        SEPARATE_ZVAL(src_entry);
                                        
-                                       convert_to_array_ex(dest_entry);
-                                       convert_to_array_ex(src_entry);
+                                       if (Z_TYPE_PP(dest_entry) == IS_NULL) {
+                                               convert_to_array_ex(dest_entry);
+                                               add_next_index_null(*dest_entry);
+                                       } else {
+                                               convert_to_array_ex(dest_entry);
+                                       }
+                                       if (Z_TYPE_PP(src_entry) == IS_NULL) {
+                                               convert_to_array_ex(src_entry);
+                                               add_next_index_null(*src_entry);
+                                       } else {
+                                               convert_to_array_ex(src_entry);
+                                       }                       
                                        if (thash) {
                                                thash->nApplyCount++;
                                        }
index 6a6a50140f720a75b405aebee9cddacf066a3963..3b251220ea79b9869c8da204db67495cf0f64873 100644 (file)
@@ -374,8 +374,10 @@ array(8) {
   object(classA)#%d (0) {
   }
   ["string"]=>
-  array(1) {
+  array(2) {
     [0]=>
+    NULL
+    [1]=>
     string(5) "hello"
   }
   ["resource"]=>