Skip to content

Commit 01ae5c3

Browse files
committed
Fixed bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS)
1 parent 188c196 commit 01ae5c3

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2013, PHP 5.3.23
44

5+
- SPL:
6+
. Fixed bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS).
7+
(patch by kriss@krizalys.com, Laruence)
8+
59

610
?? ??? 2013, PHP 5.3.22
711

ext/spl/spl_directory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,7 @@ SPL_METHOD(FilesystemIterator, __construct)
14311431
SPL_METHOD(FilesystemIterator, rewind)
14321432
{
14331433
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
1434+
int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);
14341435

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

ext/spl/tests/bug64228.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS)
3+
--FILE--
4+
<?php
5+
$dirs = array();
6+
$empty_dir = __DIR__ . "/empty";
7+
@mkdir($empty_dir);
8+
9+
$i = new RecursiveDirectoryIterator($empty_dir, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO); // Note the absence of FilesystemIterator::SKIP_DOTS
10+
foreach ($i as $key => $value) {
11+
$dirs[] = $value->getFileName();
12+
}
13+
14+
@rmdir($empty_dir);
15+
16+
sort($dirs);
17+
print_r($dirs);
18+
?>
19+
--EXPECT--
20+
Array
21+
(
22+
[0] => .
23+
[1] => ..
24+
)
25+

0 commit comments

Comments
 (0)