Bug #79852 [Opn->Csd]: count(DOMNodeList) doesn't match count(IteratorIterator(DOMNodeList))
| From: | nikic@php.net | Date: | Tue, 14 Jul 2020 10:31:35 +0000 |
| Subject: | Bug #79852 [Opn->Csd]: count(DOMNodeList) doesn't match count(IteratorIterator(DOMNodeList)) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228031@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79852&edit=1
ID: 79852
Updated by: nikic@php.net
Reported by: sjon@php.net
Summary: count(DOMNodeList) doesn't match
count(IteratorIterator(DOMNodeList))
-Status: Open
+Status: Closed
Type: Bug
Package: SimpleXML related
Operating System: archLinux
PHP Version: 8.0.0alpha2
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2020-07-13 13:33:27] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79852&edit=1