mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix Folder::tree() when excluding dot files or folders.
When 'exclude' param is array('.') files/folders are not skipped. Added test.
This commit is contained in:
parent
1dbafe1d4f
commit
c40d132f81
2 changed files with 4 additions and 5 deletions
|
@ -476,6 +476,9 @@ class FolderTest extends CakeTestCase {
|
||||||
$result = $Folder->tree(null, true);
|
$result = $Folder->tree(null, true);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $Folder->tree(null, array('.'));
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array(
|
array(
|
||||||
$Folder->path,
|
$Folder->path,
|
||||||
|
|
|
@ -413,10 +413,6 @@ class Folder {
|
||||||
|
|
||||||
if (is_array($exceptions)) {
|
if (is_array($exceptions)) {
|
||||||
$exceptions = array_flip($exceptions);
|
$exceptions = array_flip($exceptions);
|
||||||
if (isset($exceptions['.'])) {
|
|
||||||
$skipHidden = true;
|
|
||||||
unset($exceptions['.']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$skipHidden = false;
|
$skipHidden = false;
|
||||||
if ($exceptions === true) {
|
if ($exceptions === true) {
|
||||||
|
@ -435,7 +431,7 @@ class Folder {
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$pathLength = strlen($path);
|
|
||||||
foreach ($iterator as $itemPath => $fsIterator) {
|
foreach ($iterator as $itemPath => $fsIterator) {
|
||||||
if ($skipHidden) {
|
if ($skipHidden) {
|
||||||
$subPathName = $fsIterator->getSubPathname();
|
$subPathName = $fsIterator->getSubPathname();
|
||||||
|
|
Loading…
Reference in a new issue