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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lingtalfi at gmail dot com
New email:
PHP Version: OS:

 

 [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: Wed Mar 27 00:01:27 2019 UTC