Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions system/Helpers/filesystem_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,11 @@ function get_dir_file_info(string $sourceDir, bool $topLevelOnly = true, bool $r
if (is_dir($sourceDir . $file) && $file[0] !== '.' && $topLevelOnly === false) {
get_dir_file_info($sourceDir . $file . DIRECTORY_SEPARATOR, $topLevelOnly, true);
} elseif ($file[0] !== '.') {
$fileData[$file] = get_file_info($sourceDir . $file);
$fileData[$file]['relative_path'] = $relativePath;
$info = get_file_info($sourceDir . $file);
if ($info !== null) {
$fileData[$file] = $info;
$fileData[$file]['relative_path'] = $relativePath;
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions tests/system/Helpers/FilesystemHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,22 @@ public function testGetDirFileInfoFailure(): void
$this->assertSame($expected, get_dir_file_info(SUPPORTPATH . 'Files#baker'));
}

public function testGetDirFileInfoIgnoresDirectoriesWhenTopLevelOnlyIsTrue(): void
{
$dir = WRITEPATH . 'test_get_dir_file_info';
mkdir($dir . '/subdir', 0777, true);
file_put_contents($dir . '/file.txt', 'test');

$result = get_dir_file_info($dir, true);

unlink($dir . '/file.txt');
rmdir($dir . '/subdir');
rmdir($dir);

$this->assertArrayHasKey('file.txt', $result);
$this->assertArrayNotHasKey('subdir', $result);
}

public function testGetFileInfo(): void
{
$file = SUPPORTPATH . 'Files/baker/banana.php';
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.7.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Bugs Fixed

- **CLIRequest:** Fixed a bug where ``parseCommand()`` could throw a TypeError when ``argv`` is missing.
- **Content Security Policy:** Fixed a bug where empty ``Content-Security-Policy``, ``Content-Security-Policy-Report-Only``, and ``Reporting-Endpoints`` response headers were generated when no corresponding values existed.
- **Helpers:** Fixed a bug where ``get_dir_file_info()`` returned incomplete entries for subdirectories and missing files instead of omitting them.
- **Logger:** Fixed a bug where interpolating a log message with array or non-stringable context values could raise PHP warnings or errors.

See the repo's
Expand Down
Loading