From c40d132f815f8abb422e59ef30d1c86466a99c2d Mon Sep 17 00:00:00 2001 From: Majna Date: Fri, 17 Feb 2012 20:46:52 +0100 Subject: [PATCH] Fix Folder::tree() when excluding dot files or folders. When 'exclude' param is array('.') files/folders are not skipped. Added test. --- lib/Cake/Test/Case/Utility/FolderTest.php | 3 +++ lib/Cake/Utility/Folder.php | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 2664d16fe..99b7a3d3f 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -476,6 +476,9 @@ class FolderTest extends CakeTestCase { $result = $Folder->tree(null, true); $this->assertEquals($expected, $result); + $result = $Folder->tree(null, array('.')); + $this->assertEquals($expected, $result); + $expected = array( array( $Folder->path, diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index fa9e821fd..d523ea7d3 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -413,10 +413,6 @@ class Folder { if (is_array($exceptions)) { $exceptions = array_flip($exceptions); - if (isset($exceptions['.'])) { - $skipHidden = true; - unset($exceptions['.']); - } } $skipHidden = false; if ($exceptions === true) { @@ -435,7 +431,7 @@ class Folder { } return array(); } - $pathLength = strlen($path); + foreach ($iterator as $itemPath => $fsIterator) { if ($skipHidden) { $subPathName = $fsIterator->getSubPathname();