Skip to content

Commit

Permalink
[5.x] Fix 404s due to entry uri caching changes (#9998)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed May 4, 2024
1 parent c43c663 commit 993aeb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
17 changes: 4 additions & 13 deletions src/Stache/Stores/CollectionEntriesStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/Data/Entries/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 993aeb1

Please sign in to comment.