summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2012-07-02 11:33:38 +0800
committerXinchen Hui <laruence@php.net>2012-07-02 11:33:38 +0800
commitbe4053cea0462c9de5396641f4e4fa2f56f5a675 (patch)
treed11d1c9b8c6d6766823994a65d4b2f0610ed3dd2
parentff41bfc87882440cfde0ed5673bd6c3f2347c892 (diff)
downloadphp-git-be4053cea0462c9de5396641f4e4fa2f56f5a675.tar.gz
Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to dot files).
-rw-r--r--NEWS2
-rwxr-xr-xext/spl/spl_directory.c3
-rw-r--r--ext/spl/tests/bug62433.phpt18
3 files changed, 22 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 6dd1feb777..70a8eb9ec0 100644
--- a/NEWS
+++ b/NEWS
@@ -76,6 +76,8 @@ PHP NEWS
. Fixed bug #62025 (__ss_family was changed on AIX 5.3). (Felipe)
- SPL:
+ . Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to
+ dot files). (Laruence)
. Fixed bug #62262 (RecursiveArrayIterator does not implement Countable).
(Nikita Popov)
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index dbae3e2a09..0fcbd317e3 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1432,6 +1432,7 @@ SPL_METHOD(FilesystemIterator, __construct)
SPL_METHOD(FilesystemIterator, rewind)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+ int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1443,7 +1444,7 @@ SPL_METHOD(FilesystemIterator, rewind)
}
do {
spl_filesystem_dir_read(intern TSRMLS_CC);
- } while (spl_filesystem_is_dot(intern->u.dir.entry.d_name));
+ } while (skip_dots && spl_filesystem_is_dot(intern->u.dir.entry.d_name));
}
/* }}} */
diff --git a/ext/spl/tests/bug62433.phpt b/ext/spl/tests/bug62433.phpt
new file mode 100644
index 0000000000..86b5df8387
--- /dev/null
+++ b/ext/spl/tests/bug62433.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #62433 Inconsistent behavior of RecursiveDirectoryIterator to dot files (. and ..)
+--FILE--
+<?php
+$dots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__)));
+$ndots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS)));
+
+var_dump(in_array(__DIR__ . '/.', $dots));
+var_dump(in_array(__DIR__ . '/..', $dots));
+
+var_dump(in_array(__DIR__ . '/.', $ndots));
+var_dump(in_array(__DIR__ . '/..', $ndots));
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+bool(false)