diff --git a/system/Autoloader/FileLocatorCached.php b/system/Autoloader/FileLocatorCached.php index 0aa267b2a84b..3e31a33d9e84 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); - $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..37f7eebdfaa1 100644 --- a/tests/system/Validation/RulesTest.php +++ b/tests/system/Validation/RulesTest.php @@ -669,7 +669,7 @@ public static function provideInList(): iterable } #[DataProvider('provideRequiredWith')] - public function testRequiredWith(?string $field, ?string $check, bool $expected): void + public function testRequiredWith(string $field, ?string $check, bool $expected): void { $data = [ 'foo' => 'bar', @@ -693,8 +693,8 @@ public static function provideRequiredWith(): iterable ['nope', 'bar', false], ['foo', 'bar', true], ['nope', 'baz', true], - [null, null, true], - [null, 'foo', false], + ['', null, true], + ['', 'foo', false], ['foo', null, true], [ 'array.emptyField1', @@ -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',