Commit:    01ae5c3c2ff47ca66031ec4a750a30d97c64c492
Author:    Xinchen Hui <larue...@php.net>         Sun, 17 Feb 2013 11:04:36 
+0800
Parents:   188c196d4da60bdde9190d2fc532650d17f7af2d
Branches:  PHP-5.3

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

Log:
Fixed bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS)

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

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


Diff:
diff --git a/NEWS b/NEWS
index e4ee218..26d56cc 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP                                                            
            NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2013, PHP 5.3.23
 
+- SPL:
+  . Fixed bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS).
+    (patch by kr...@krizalys.com, Laruence)
+
 
 ?? ??? 2013, PHP 5.3.22
 
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 1b6a0e9..13af781 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1431,6 +1431,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;
@@ -1442,7 +1443,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/bug64228.phpt b/ext/spl/tests/bug64228.phpt
new file mode 100644
index 0000000..3f30dd2
--- /dev/null
+++ b/ext/spl/tests/bug64228.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS)
+--FILE--
+<?php
+$dirs = array();
+$empty_dir = __DIR__ . "/empty";
+@mkdir($empty_dir);
+
+$i = new RecursiveDirectoryIterator($empty_dir, 
FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO); 
// Note the absence of FilesystemIterator::SKIP_DOTS
+foreach ($i as $key => $value) {
+    $dirs[] = $value->getFileName();
+}
+
+@rmdir($empty_dir);
+
+sort($dirs);
+print_r($dirs);
+?>
+--EXPECT--
+Array
+(
+    [0] => .
+    [1] => ..
+)
+


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

Reply via email to