From 993aeb1511b94e2183f6428541089bec396ba00b Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Sat, 4 May 2024 08:21:08 -0400 Subject: [PATCH] [5.x] Fix 404s due to entry uri caching changes (#9998) --- src/Stache/Stores/CollectionEntriesStore.php | 17 ++++------------- tests/Data/Entries/EntryTest.php | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/Stache/Stores/CollectionEntriesStore.php b/src/Stache/Stores/CollectionEntriesStore.php index ff6df06611..6c2d8358bd 100644 --- a/src/Stache/Stores/CollectionEntriesStore.php +++ b/src/Stache/Stores/CollectionEntriesStore.php @@ -225,28 +225,19 @@ protected function writeItemToDisk($item) $item->writeFile($path); } - protected function cacheItem($item) - { - $key = $this->getItemKey($item); - - $cacheKey = $this->getItemCacheKey($key); - - Cache::forever($cacheKey, ['entry' => $item, 'uri' => $item->uri()]); - } - protected function getCachedItem($key) { $cacheKey = $this->getItemCacheKey($key); - if (! $cache = Cache::get($cacheKey)) { + if (! $entry = Cache::get($cacheKey)) { return null; } - if ($this->shouldBlinkEntryUris && $cache['uri']) { - Blink::store('entry-uris')->put($cache['entry']->id(), $cache['uri']); + if ($this->shouldBlinkEntryUris && ($uri = $this->resolveIndex('uri')->load()->get($entry->id()))) { + Blink::store('entry-uris')->put($entry->id(), $uri); } - return $cache['entry']; + return $entry; } public function withoutBlinkingEntryUris($callback) diff --git a/tests/Data/Entries/EntryTest.php b/tests/Data/Entries/EntryTest.php index 4b1bdc26f5..f2967fa4b0 100644 --- a/tests/Data/Entries/EntryTest.php +++ b/tests/Data/Entries/EntryTest.php @@ -1354,7 +1354,7 @@ public function when_saving_quietly_the_cached_entrys_withEvents_flag_will_be_se $entry->saveQuietly(); - $cached = Cache::get('stache::items::entries::blog::1')['entry']; + $cached = Cache::get('stache::items::entries::blog::1'); $reflection = new ReflectionClass($cached); $property = $reflection->getProperty('withEvents'); $property->setAccessible(true);