Bug #76901 [NEW]: method_exists + RecursiveDirectoryIterator::getSubPathName conflict
| From: | p dot bytniewski at neurosys dot com | Date: | Wed, 19 Sep 2018 06:14:33 +0000 |
| Subject: | Bug #76901 [NEW]: method_exists + RecursiveDirectoryIterator::getSubPathName conflict | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-217132@lists.php.net to get a copy of this message | ||
From: p dot bytniewski at neurosys dot com
Operating system: Linux - debian based
PHP version: 7.2.10
Package: SPL related
Bug Type: Bug
Bug description:method_exists + RecursiveDirectoryIterator::getSubPathName conflict
Description:
------------
Having the following directory structure:
./directory
./directory/subdirectory
./directory/subdirectory/file2
./directory/subdirectory/file1
when executing the provided test script, after encountering second file
there seems to be some corruption. If there's no call to method_exists,
everything works fine.
Test script:
---------------
<?php
$path = 'directory';
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path,
RecursiveDirectoryIterator::SKIP_DOTS)
);
foreach($iterator as $it)
{
if (!method_exists($iterator, 'getSubPathName')) {
throw new \LogicException('This should never happen');
}
echo $iterator->getSubPathName(). PHP_EOL;
}
Expected result:
----------------
subdirectory/file2
subdirectory/file1
Actual result:
--------------
subdirectory/file2
pf��/file1
PHP Fatal error: Couldn't execute method
RecursiveDirectoryIterator::next in Unknown on line 0
PHP Stack trace:
PHP 1. {main}() path/to/file/iterator.php:0
--
Edit bug report at https://bugs.php.net/bug.php?id=76901&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76901&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76901&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76901&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76901&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76901&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76901&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76901&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76901&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76901&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76901&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76901&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76901&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76901&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76901&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76901&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76901&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76901&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76901&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76901&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76901&r=mysqlcfg