wrong result with DOMNodeList and iterator_to_array use_keys

 [2011-06-01 16:12 UTC] jinmoku at hotmail dot com

Description:
------------
when you pass a DOMNodeList in iterator_to_array there a weird result with use_keys on true

Test script:
---------------
$source = <<<XML
<root>
    <node>val1</node>
    <node>val2</node>
</root>
XML;

$doc = new DOMDocument();
$doc->loadXML($source);
     
$xpath = new DOMXPath($doc);
$items = $xpath->query('//node');

print_r(iterator_to_array($items, true));
print_r(iterator_to_array($items, false));

Expected result:
----------------
Array
(
    [0] => DOMElement Object
        (
        )

    [1] => DOMElement Object
        (
        )

)
Array
(
    [0] => DOMElement Object
        (
        )

    [1] => DOMElement Object
        (
        )

)

Actual result:
--------------
Array
(
    [6646882] => DOMElement Object
        (
        )

)
Array
(
    [0] => DOMElement Object
        (
        )

    [1] => DOMElement Object
        (
        )

)

 [2011-06-29 19:14 UTC] pierrick@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2011-08-30 04:18 UTC] datibbaw@php.net

The test got marked as failed on my machine, because of --disable-dom

Attached a patch to skip the test in those cases ;-)