From cc19412bca4fc21c39446943bbaf70eb7fe81dda Mon Sep 17 00:00:00 2001 From: Vadim Dvorovenko Date: Sat, 22 Nov 2025 15:14:41 +0700 Subject: [PATCH 1/2] [12.x] MemoizedStoreTest with empty prefix --- tests/Integration/Cache/MemoizedStoreTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Integration/Cache/MemoizedStoreTest.php b/tests/Integration/Cache/MemoizedStoreTest.php index 74022ea8527d..1adc87283573 100644 --- a/tests/Integration/Cache/MemoizedStoreTest.php +++ b/tests/Integration/Cache/MemoizedStoreTest.php @@ -121,6 +121,21 @@ public function test_it_uses_correct_keys_for_getMultiple() $this->assertSame($cacheValue, $memoValue); } + public function test_it_uses_correct_keys_for_getMultiple_with_empty_prefix() + { + Cache::setPrefix(null); + + $data = [ + '1' => 'one', + 0 => 'zero', + ]; + Cache::putMany($data); + + $this->assertSame($data, Cache::memo()->many(array_keys($data))); + // ensure correct on the second memoized retrieval + $this->assertSame($data, Cache::memo()->many(array_keys($data))); + } + public function test_null_values_are_memoized_when_retrieving_multiple_values() { $live = Cache::getMultiple(['name.0', 'name.1']); From 9264a02b6dab6f676665309a3d55e563bb0bdc2f Mon Sep 17 00:00:00 2001 From: Vadim Dvorovenko Date: Sat, 22 Nov 2025 15:38:04 +0700 Subject: [PATCH 2/2] [12.x] MemoizedStore fix with empty prefix and numeric keys --- src/Illuminate/Cache/MemoizedStore.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Cache/MemoizedStore.php b/src/Illuminate/Cache/MemoizedStore.php index 6c24e33346ce..e864e1ec2c86 100644 --- a/src/Illuminate/Cache/MemoizedStore.php +++ b/src/Illuminate/Cache/MemoizedStore.php @@ -68,12 +68,9 @@ public function many(array $keys) if (count($missing) > 0) { $retrieved = tap($this->repository->many($missing), function ($values) { - $this->cache = [ - ...$this->cache, - ...collect($values)->mapWithKeys(fn ($value, $key) => [ - $this->prefix($key) => $value, - ]), - ]; + foreach ($values as $key => $value) { + $this->cache[$this->prefix($key)] = $value; + } }); }