#43559 [NEW]: array_merge_recursive() doesn't behave as expected with duplicate NULL values

From: Date: Tue, 11 Dec 2007 05:35:06 +0000
Subject: #43559 [NEW]: array_merge_recursive() doesn't behave as expected with duplicate NULL values
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120547@lists.php.net to get a copy of this message
From: kraghuba at in dot ibm dot com Operating system: Linux, windows PHP version: 5.2CVS-2007-12-11 (snap) PHP Bug Type: Arrays related Bug description: array_merge_recursive() doesn't behave as expected with duplicate NULL values Description: ------------ When two arrays having common key and value are passed as argument to array_merge_recursive(), the function behaves in an unexpected way for NULL values. It outputs an empty array instead of an array having two elements, both being NULL. Whereas, the function behaves in an expected way with values other than NULL. This behavior can be observed in the testcase array_merge_recursive_variation9.phpt. This behavior is observed in PHP5.3 and PHP6 as well. I tried creating an array with two null values and it works: <?php $a = array(NULL, NULL); var_dump($a); ?> output: array(2) { [0]=> NULL [1]=> NULL } Reproduce code: --------------- <?php $a1 = array( 'b' => 'string' ); $a2 = array( 'b' => 'string' ); $a3 = array( 'b' => NULL ); $a4 = array( 'b' => NULL ); var_dump( array_merge_recursive($a1, $a2) ); // expected output var_dump( array_merge_recursive($a3, $a4) ); // unexpecteed output ?> Expected result: ---------------- array(1) { ["b"]=> array(2) { [0]=> string(6) "string" [1]=> string(6) "string" } } array(1) { ["b"]=> array(2) { [0]=> NULL [1]=> NULL } } Actual result: -------------- array(1) { ["b"]=> array(2) { [0]=> string(6) "string" [1]=> string(6) "string" } } array(1) { ["b"]=> array(0) { } } -- Edit bug report at http://bugs.php.net/?id=43559&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43559&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43559&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43559&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43559&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43559&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43559&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43559&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43559&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43559&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43559&r=support Expected behavior: http://bugs.php.net/fix.php?id=43559&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43559&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43559&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43559&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43559&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43559&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43559&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43559&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43559&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43559&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43559&r=mysqlcfg

« previous php.bugs (#120547) next »