php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54971 wrong result with DOMNodeList and iterator_to_array use_keys
Submitted: 2011-06-01 16:12 UTC Modified: 2011-08-30 04:18 UTC
From: jinmoku at hotmail dot com Assigned: pierrick (profile)
Status: Closed Package: DOM XML related
PHP Version: 5.3.6 OS: Win 7
Private report: No CVE-ID: None
 [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
        (
        )

)

Patches

bug54971.phpt.patch (last revision 2011-08-30 13:19 UTC by datibbaw@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-03 03:49 UTC] felipe@php.net
-Status: Open +Status: Verified
 [2011-06-04 09:58 UTC] pierrick@php.net
-Assigned To: +Assigned To: pierrick
 [2011-06-29 19:14 UTC] pierrick@php.net
-Status: Verified +Status: Closed
 [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:16 UTC] datibbaw@php.net
The following patch has been added/updated:

Patch Name: bug54971.phpt.patch
Revision:   1314677817
URL:        https://bugs.php.net/patch-display.php?bug=54971&patch=bug54971.phpt.patch&revision=1314677817
 [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 ;-)
 [2011-08-30 13:19 UTC] datibbaw@php.net
The following patch has been added/updated:

Patch Name: bug54971.phpt.patch
Revision:   1314710371
URL:        https://bugs.php.net/patch-display.php?bug=54971&patch=bug54971.phpt.patch&revision=1314710371
 [2011-08-30 13:46 UTC] bjori@php.net
Automatic comment from SVN on behalf of bjori
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=315780
Log: Add skipifs for bug#54971 (patch by datibbaw@)
 [2012-04-18 09:50 UTC] laruence@php.net
Automatic comment on behalf of pierrick
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e53ca46fc06ce3e45ef5af4c5380a152d4707a2c
Log: Fixed bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
 [2012-07-24 23:41 UTC] rasmus@php.net
Automatic comment on behalf of pierrick
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e53ca46fc06ce3e45ef5af4c5380a152d4707a2c
Log: Fixed bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
 [2013-11-17 09:37 UTC] laruence@php.net
Automatic comment on behalf of pierrick
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e53ca46fc06ce3e45ef5af4c5380a152d4707a2c
Log: Fixed bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC