php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67945 SKIP_DOTS incorrect behaviour ?
Submitted: 2014-09-01 17:25 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: lingtalfi at gmail dot com Assigned:
Status: Open Package: SPL related
PHP Version: 5.6.0 OS: MacOsX 10.8.5
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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.









Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-27 12:14 UTC] gmblar+php at gmail dot com
<?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)
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Mar 26 14:01:27 2019 UTC