|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-09-01 17:25 UTC] lingtalfi at gmail dot com
Description: ------------ It seems that the \FilesystemIterator::SKIP_DOTS flag has some sort of conflict with files starting with a dot, like .htaccess for instance. Test script: --------------- I put some code there: http://ideone.com/wkECMO The expected output is to have one match (=one line) which is: pathname: /tmp/test/mydir, filename: mydir Now if you uncomment line 27 (with SKIP_DOTS flag on), the output is two lines: pathname: /tmp/test/mydir, filename: mydir pathname: /tmp/test/mydir, filename: mydir But one was expected. Alternatively, you can enable SKIP_DOTS, and remove either the DirFilterIterator, or the \AppendIterator and (at least in my case) you get only one match. But as long as DirFilterIterator and \AppendIterator are used together, it seems that SKIP_DOTS messes the things up. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 01:00:01 2025 UTC |
<?php $dir = '/tmp/test'; @mkdir($dir, 0777, true); touch($dir . '/.anyhidden'); @mkdir($dir . '/mydir'); $recursiveDirectoryIterator = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS); $recursiveIteratorIterator = new RecursiveIteratorIterator($recursiveDirectoryIterator, RecursiveIteratorIterator::SELF_FIRST); var_dump(iterator_count($recursiveIteratorIterator)); var_dump(iterator_count($recursiveIteratorIterator)); $filterIterator = new CallbackFilterIterator($recursiveIteratorIterator, function($current) { return $current->isDir(); }); var_dump(iterator_count($filterIterator)); var_dump(iterator_count($filterIterator)); $appendIterator = new AppendIterator(); $appendIterator->append($filterIterator); var_dump(iterator_count($appendIterator)); var_dump(iterator_count($appendIterator)); Expected result: int(2) int(2) int(1) int(1) int(1) int(1) Actual result: int(2) int(2) int(1) int(1) int(2) int(1)