Bug #72692 [NEW]: Bad behaviour of AppendIterator with Empty Generator
| From: | pierrick@php.net | Date: | Thu, 28 Jul 2016 05:09:14 +0000 |
| Subject: | Bug #72692 [NEW]: Bad behaviour of AppendIterator with Empty Generator | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-202653@lists.php.net to get a copy of this message | ||
From: pierrick
Operating system:
PHP version: 5.6.24
Package: SPL related
Bug Type: Bug
Bug description:Bad behaviour of AppendIterator with Empty Generator
Description:
------------
When giving an new empty generator, AppendIterator will directly throw
an Exception "Cannot traverse an already closed generator" even if the
given generator is new.
Test script:
---------------
<?php
function createEmptyGen() { if(false) { yield 1; } }
$gen = createEmptyGen();
$ai = new AppendIterator();
$ai->append($gen);
var_dump(iterator_to_array($gen));
Expected result:
----------------
array(0) {
}
Actual result:
--------------
Fatal error: Uncaught Exception: Cannot traverse an already closed
generator in /home/pierrick/php-src/github/foo.php:14
Stack trace:
#0 /home/pierrick/php-src/github/foo.php(14):
iterator_to_array(Object(Generator))
#1 {main}
thrown in /home/pierrick/php-src/github/foo.php on line 14
--
Edit bug report at https://bugs.php.net/bug.php?id=72692&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72692&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72692&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72692&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72692&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72692&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72692&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72692&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72692&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72692&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72692&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72692&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72692&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72692&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72692&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72692&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72692&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72692&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72692&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72692&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72692&r=mysqlcfg