From c4647ec2a47c3d0f4def7b19bb1ae5fef34e761f Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Wed, 22 May 2024 15:36:49 -0400 Subject: [PATCH] [5.x] Fix routeData on null error (#10169) --- src/Stache/Indexes/Index.php | 10 ++++++++++ src/Stache/Stores/CollectionEntriesStore.php | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Stache/Indexes/Index.php b/src/Stache/Indexes/Index.php index c147917cd0..0375a92814 100644 --- a/src/Stache/Indexes/Index.php +++ b/src/Stache/Indexes/Index.php @@ -12,6 +12,7 @@ abstract class Index protected $name; protected $items = []; protected $loaded = false; + private static ?string $currentlyLoading = null; public function __construct($store, $name) { @@ -65,6 +66,8 @@ public function load() return $this; } + static::$currentlyLoading = $this->store->key().'/'.$this->name; + $this->loaded = true; if (Statamic::isWorker()) { @@ -81,6 +84,8 @@ public function load() $this->store->cacheIndexUsage($this); + static::$currentlyLoading = null; + return $this; } @@ -150,4 +155,9 @@ public function clear() Cache::forget($this->cacheKey()); } + + public static function currentlyLoading() + { + return static::$currentlyLoading; + } } diff --git a/src/Stache/Stores/CollectionEntriesStore.php b/src/Stache/Stores/CollectionEntriesStore.php index 6c2d8358bd..b045e214c7 100644 --- a/src/Stache/Stores/CollectionEntriesStore.php +++ b/src/Stache/Stores/CollectionEntriesStore.php @@ -15,6 +15,7 @@ use Statamic\Facades\Site; use Statamic\Facades\YAML; use Statamic\Stache\Indexes; +use Statamic\Stache\Indexes\Index; use Statamic\Support\Arr; use Statamic\Support\Str; use Symfony\Component\Finder\SplFileInfo; @@ -233,7 +234,9 @@ protected function getCachedItem($key) return null; } - if ($this->shouldBlinkEntryUris && ($uri = $this->resolveIndex('uri')->load()->get($entry->id()))) { + $isLoadingIds = Index::currentlyLoading() === $this->key().'/id'; + + if (! $isLoadingIds && $this->shouldBlinkEntryUris && ($uri = $this->resolveIndex('uri')->load()->get($entry->id()))) { Blink::store('entry-uris')->put($entry->id(), $uri); }