Commit:    be4053cea0462c9de5396641f4e4fa2f56f5a675
Author:    Xinchen Hui <larue...@php.net>         Mon, 2 Jul 2012 11:33:38 +0800
Parents:   ff41bfc87882440cfde0ed5673bd6c3f2347c892
Branches:  PHP-5.4

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=be4053cea0462c9de5396641f4e4fa2f56f5a675

Log:
Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to dot 
files).

Bugs:
https://bugs.php.net/62433

Changed paths:
  M  NEWS
  M  ext/spl/spl_directory.c
  A  ext/spl/tests/bug62433.phpt


Diff:
diff --git a/NEWS b/NEWS
index 6dd1feb..70a8eb9 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 dbae3e2..0fcbd31 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 0000000..86b5df8
--- /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)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to