Bug #76901 [Opn->Ver]: method_exists + RecursiveDirectoryIterator::getSubPathName conflict
| From: | nikic@php.net | Date: | Wed, 19 Sep 2018 06:34:33 +0000 |
| Subject: | Bug #76901 [Opn->Ver]: method_exists + RecursiveDirectoryIterator::getSubPathName conflict | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217134@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76901&edit=1
ID: 76901
Updated by: nikic@php.net
Reported by: p dot bytniewski at neurosys dot com
Summary: method_exists +
RecursiveDirectoryIterator::getSubPathName conflict
-Status: Open
+Status: Verified
Type: Bug
Package: SPL related
Operating System: Linux - debian based
PHP Version: 7.2.10
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2018-09-19 06:14:33] p dot bytniewski at neurosys dot com
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 this bug report at https://bugs.php.net/bug.php?id=76901&edit=1