Bug #79852 [NEW]: count(DOMNodeList) doesn't match count(IteratorIterator(DOMNodeList))

From: Date: Mon, 13 Jul 2020 13:33:27 +0000
Subject: Bug #79852 [NEW]: count(DOMNodeList) doesn't match count(IteratorIterator(DOMNodeList))
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228012@lists.php.net to get a copy of this message
From:             sjon
Operating system: archLinux
PHP version:      8.0.0alpha2
Package:          SimpleXML related
Bug Type:         Bug
Bug description:count(DOMNodeList) doesn't match count(IteratorIterator(DOMNodeList))

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 bug report at https://bugs.php.net/bug.php?id=79852&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79852&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79852&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79852&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79852&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79852&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79852&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79852&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79852&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79852&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79852&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79852&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79852&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79852&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79852&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79852&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79852&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79852&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#228012) next »