|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-09-19 06:14 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Also happens under Windows 10; except there is no fatal error reported; also affects $iterator->getSubPath(); garbage varies from run to run. With a slightly deeper directory tree: . └───directory ├───dir │ └───again │ ├───file3.txt │ ├───file4.txt │ └───file5.txt └───subdirectory ├───file1.txt └───file2.txt The result is: dir\again\file3.txt @1Gl\file4.txt subdirectory\file1.txt ` @l\file2.txt