Mantis - Quercus
Viewing Issue Advanced Details
1103 minor always 05-12-06 20:35 05-15-06 15:04
koreth  
ferg  
normal  
closed 3.0.19  
fixed  
none    
none 3.0.20  
0001103: array_merge() doesn't deal properly with NULL argument (w/fix)
<?php
$array = array_merge((array)NULL, (array)NULL);
var_dump($array);
?>

Quercus outputs an array of two NULL elements. Normal PHP outputs an empty array.

Fix is to replace

      if (! (arg.toValue() instanceof ArrayValue))

with

      if (! (arg.toValue() instanceof ArrayValue) || arg.toValue().isNull())

in ArrayModule.array_merge().

Notes
(0001125)
koreth   
05-12-06 20:47   
Hmm, scratch that fix -- it seemed to work once but now it doesn't. And I don't see how it worked even once, since ArrayValueImpl.isNull() always returns false. This will need a different fix.
(0001126)
koreth   
05-12-06 21:07   
Okay, the real problem here is that (array)NULL is {NULL} rather than {}. The fix is to override toArray() in NullValue to return an empty ArrayValueImpl().
(0001129)
ferg   
05-15-06 15:04   
php/173e