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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
21 + 30 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 05:01:28 2024 UTC