php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79852 count(DOMNodeList) doesn't match count(IteratorIterator(DOMNodeList))
Submitted: 2020-07-13 13:33 UTC Modified: -
From: sjon@php.net Assigned:
Status: Closed Package: SimpleXML related
PHP Version: 8.0.0alpha2 OS: archLinux
Private report: No CVE-ID: None
 [2020-07-13 13:33 UTC] sjon@php.net
Description:
------------
Originally found as https://3v4l.org/LtSmU - it seems the new SimpleXMLIterator broke something wrt iterator_iterator, there is a mismatch in counts, and count(IteratorIterator(DOMNodeList)) throws an Exception that doesn't seem necessary

Test script:
---------------
$XML = <<< XML
<root>
  <item>1</item>
  <item>2</item>
  <item>3</item>
</root>
XML;

$dom = new DomDocument();
$dom->loadXml($XML);
$items = $dom->getElementsByTagName('item');

echo "Count: ".count($items). PHP_EOL;
$it = new IteratorIterator($items);
$c = iterator_count($it);
echo "Count: $c", PHP_EOL;


Expected result:
----------------
Count: 3
Count: 3

Actual result:
--------------
Count: 3
Count: 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-14 10:31 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=70501b81a75c7c4cd0ec3a121e290e561829deb9
Log: Fixed bug #79852
 [2020-07-14 10:31 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC