Bug #80660 [Com]: FilesystemIterator foreach-loop fails on fuse filesystems

From: Date: Fri, 30 Apr 2021 02:19:18 +0000
Subject: Bug #80660 [Com]: FilesystemIterator foreach-loop fails on fuse filesystems
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233624@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80660&edit=1 ID: 80660 Comment by: marcelo at ofload dot com Reported by: shop1 at mokraemer dot de Summary: FilesystemIterator foreach-loop fails on fuse filesystems Status: Open Type: Bug Package: *Directory/Filesystem functions Operating System: linux PHP Version: 7.4.14 Block user comment: N Private report: N New Comment: I'm having a similar issue. In your example, if you don't rewind() it works. i.e. - create the iterator - while() - foreach() But I can also see an issue where if you rewind() before while() it fails. i.e. - create the iterator - rewind() - while() Also, if we do foreach() before while() it fails: i.e. - create the iterator - foreach() - rewind() - while() In summary, depending if you call rewind() or not calling rewind() it fails for foreach() or while() too. This is a very awkward bug that is happening in a Docker container with Windows as a Host. Previous Comments: ------------------------------------------------------------------------ [2021-01-22 13:53:36] shop1 at mokraemer dot de Description: ------------ As for my testing, FilesystemIterator fails with the foreach loop while the while-next loop works as expected. Test script: --------------- <?php $iterator = new \FilesystemIterator( '/fuse-filesystem', \FilesystemIterator::CURRENT_AS_SELF | \FilesystemIterator::SKIP_DOTS ); echo "--while\n"; while($iterator->valid()) { echo $iterator->current()."\n"; $iterator->next(); } $iterator->rewind(); echo "--for\n"; foreach ($iterator as $entry) { echo $entry->getFilename()."\n"; } Expected result: ---------------- --while .hg file1.class.php file2.class.php --for .hg file1.class.php file2.class.php Actual result: -------------- --while .hg file1.class.php file2.class.php --for ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80660&edit=1

« previous php.bugs (#233624) next »