From 18bdafb38118fb6f2db94205fea8252a03e57b78 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 14 Jul 2026 20:42:41 +0200 Subject: [PATCH 1/4] fix: prevent null pointer errors in get_dir_file_info when get_file_info returns null --- system/Helpers/filesystem_helper.php | 6 ++++-- tests/system/Helpers/FilesystemHelperTest.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/system/Helpers/filesystem_helper.php b/system/Helpers/filesystem_helper.php index da6acabb039e..21a4d634e532 100644 --- a/system/Helpers/filesystem_helper.php +++ b/system/Helpers/filesystem_helper.php @@ -281,8 +281,10 @@ 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; + if (($info = get_file_info($sourceDir . $file)) !== null) { + $fileData[$file] = $info; + $fileData[$file]['relative_path'] = $relativePath; + } } } diff --git a/tests/system/Helpers/FilesystemHelperTest.php b/tests/system/Helpers/FilesystemHelperTest.php index a8ee76d6ab09..9d4bf74eb4e5 100644 --- a/tests/system/Helpers/FilesystemHelperTest.php +++ b/tests/system/Helpers/FilesystemHelperTest.php @@ -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'; From 57bf78668c82d878feea49bf60bd68b23fa45bc8 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 15 Jul 2026 19:01:48 +0200 Subject: [PATCH 2/4] docs: add changelog entry for PR #10407 --- user_guide_src/source/changelogs/v4.7.5.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelogs/v4.7.5.rst b/user_guide_src/source/changelogs/v4.7.5.rst index c4bb7900e07a..203f924a86a2 100644 --- a/user_guide_src/source/changelogs/v4.7.5.rst +++ b/user_guide_src/source/changelogs/v4.7.5.rst @@ -31,6 +31,7 @@ Bugs Fixed ********** - **Logger:** Fixed a bug where interpolating a log message with array or non-stringable context values could raise PHP warnings or errors. +- **filesystem_helper:** Fixed a bug where ``get_dir_file_info()`` could cause a null pointer error when ``get_file_info()`` returns null. See the repo's `CHANGELOG.md `_ From 2af39803420ab3c6952f829b679a6805206f552d Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 15 Jul 2026 19:59:35 +0200 Subject: [PATCH 3/4] chore: trigger CI From 26210e64bd7091f8edba800f936a708c1dcc4346 Mon Sep 17 00:00:00 2001 From: Bogdan Lambarski Date: Wed, 15 Jul 2026 21:48:43 +0200 Subject: [PATCH 4/4] Update user_guide_src/source/changelogs/v4.7.5.rst Co-authored-by: memleakd <121398829+memleakd@users.noreply.github.com> --- user_guide_src/source/changelogs/v4.7.5.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.7.5.rst b/user_guide_src/source/changelogs/v4.7.5.rst index 203f924a86a2..93cc9e49484e 100644 --- a/user_guide_src/source/changelogs/v4.7.5.rst +++ b/user_guide_src/source/changelogs/v4.7.5.rst @@ -31,7 +31,7 @@ Bugs Fixed ********** - **Logger:** Fixed a bug where interpolating a log message with array or non-stringable context values could raise PHP warnings or errors. -- **filesystem_helper:** Fixed a bug where ``get_dir_file_info()`` could cause a null pointer error when ``get_file_info()`` returns null. +- **Helpers:** Fixed a bug where ``get_dir_file_info()`` could cause a null pointer error when ``get_file_info()`` returns null. See the repo's `CHANGELOG.md `_