Bug #78223 [NEW]: DirectoryIterator entries invalidated after its destruction
| From: | zerkms at zerkms dot ru | Date: | Fri, 28 Jun 2019 02:01:53 +0000 |
| Subject: | Bug #78223 [NEW]: DirectoryIterator entries invalidated after its destruction | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-221526@lists.php.net to get a copy of this message | ||
From: zerkms at zerkms dot ru
Operating system: linux
PHP version: 7.3.6
Package: SPL related
Bug Type: Bug
Bug description:DirectoryIterator entries invalidated after its destruction
Description:
------------
It's reproducible on all php >= 7 versions (including 7.4-rc)
I probably am missing something, but I cannot find it documented
anywhere, hence the behaviour surprises me.
Test script:
---------------
<?php
$files = iterator_to_array(new DirectoryIterator(__DIR__));
var_dump($files[0]->getRealPath());
foreach (new DirectoryIterator(__DIR__) as $f) {
var_dump($f->getRealPath());
break;
}
Expected result:
----------------
string(4) "/app"
string(4) "/app"
Actual result:
--------------
bool(false)
string(4) "/app"
--
Edit bug report at https://bugs.php.net/bug.php?id=78223&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78223&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78223&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78223&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78223&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78223&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78223&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78223&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78223&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78223&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78223&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78223&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78223&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78223&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78223&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78223&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78223&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78223&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78223&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78223&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78223&r=mysqlcfg