Skip to content

Commit be4053c

Browse files
committed
Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to dot files).
1 parent ff41bfc commit be4053c

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ PHP NEWS
7676
. Fixed bug #62025 (__ss_family was changed on AIX 5.3). (Felipe)
7777

7878
- SPL:
79+
. Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to
80+
dot files). (Laruence)
7981
. Fixed bug #62262 (RecursiveArrayIterator does not implement Countable).
8082
(Nikita Popov)
8183

ext/spl/spl_directory.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,7 @@ SPL_METHOD(FilesystemIterator, __construct)
14321432
SPL_METHOD(FilesystemIterator, rewind)
14331433
{
14341434
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
1435+
int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);
14351436

14361437
if (zend_parse_parameters_none() == FAILURE) {
14371438
return;
@@ -1443,7 +1444,7 @@ SPL_METHOD(FilesystemIterator, rewind)
14431444
}
14441445
do {
14451446
spl_filesystem_dir_read(intern TSRMLS_CC);
1446-
} while (spl_filesystem_is_dot(intern->u.dir.entry.d_name));
1447+
} while (skip_dots && spl_filesystem_is_dot(intern->u.dir.entry.d_name));
14471448
}
14481449
/* }}} */
14491450

ext/spl/tests/bug62433.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #62433 Inconsistent behavior of RecursiveDirectoryIterator to dot files (. and ..)
3+
--FILE--
4+
<?php
5+
$dots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__)));
6+
$ndots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS)));
7+
8+
var_dump(in_array(__DIR__ . '/.', $dots));
9+
var_dump(in_array(__DIR__ . '/..', $dots));
10+
11+
var_dump(in_array(__DIR__ . '/.', $ndots));
12+
var_dump(in_array(__DIR__ . '/..', $ndots));
13+
?>
14+
--EXPECT--
15+
bool(true)
16+
bool(true)
17+
bool(false)
18+
bool(false)

0 commit comments

Comments
 (0)