diff --git a/system/Autoloader/FileLocatorCached.php b/system/Autoloader/FileLocatorCached.php index 0aa267b2a84b..28b7302f1dce 100644 --- a/system/Autoloader/FileLocatorCached.php +++ b/system/Autoloader/FileLocatorCached.php @@ -163,14 +163,16 @@ public function listNamespaceFiles(string $prefix, string $path): array public function locateFile(string $file, ?string $folder = null, string $ext = 'php'): false|string { - if (isset($this->cache['locateFile'][$file][$folder][$ext])) { - return $this->cache['locateFile'][$file][$folder][$ext]; + $folderKey = $folder ?? ''; + + if (isset($this->cache['locateFile'][$file][$folderKey][$ext])) { + return $this->cache['locateFile'][$file][$folderKey][$ext]; } - $files = $this->locator->locateFile($file, $folder, $ext); + $files = $this->locator->locateFile($file, $folderKey, $ext); - $this->cache['locateFile'][$file][$folder][$ext] = $files; - $this->cacheUpdated = true; + $this->cache['locateFile'][$file][$folderKey][$ext] = $files; + $this->cacheUpdated = true; return $files; } diff --git a/tests/system/Validation/RulesTest.php b/tests/system/Validation/RulesTest.php index 8bb6cab3ce77..14c99d5d9d78 100644 --- a/tests/system/Validation/RulesTest.php +++ b/tests/system/Validation/RulesTest.php @@ -779,7 +779,7 @@ public static function provideRequiredWithAndOtherRuleWithValueZero(): iterable } #[DataProvider('provideRequiredWithout')] - public function testRequiredWithout(?string $field, ?string $check, bool $expected): void + public function testRequiredWithout(string $field, ?string $check, bool $expected): void { $data = [ 'foo' => 'bar', @@ -802,8 +802,8 @@ public static function provideRequiredWithout(): iterable yield from [ ['nope', 'bars', false], ['foo', 'nope', true], - [null, null, false], - [null, 'foo', true], + ['', null, false], + ['', 'foo', true], ['foo', null, true], [ 'array.emptyField1',