Skip to content

Commit

Permalink
[5.x] Fix routeData on null error (#10169)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed May 22, 2024
1 parent 8d53d95 commit c4647ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Stache/Indexes/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ abstract class Index
protected $name;
protected $items = [];
protected $loaded = false;
private static ?string $currentlyLoading = null;

public function __construct($store, $name)
{
Expand Down Expand Up @@ -65,6 +66,8 @@ public function load()
return $this;
}

static::$currentlyLoading = $this->store->key().'/'.$this->name;

$this->loaded = true;

if (Statamic::isWorker()) {
Expand All @@ -81,6 +84,8 @@ public function load()

$this->store->cacheIndexUsage($this);

static::$currentlyLoading = null;

return $this;
}

Expand Down Expand Up @@ -150,4 +155,9 @@ public function clear()

Cache::forget($this->cacheKey());
}

public static function currentlyLoading()
{
return static::$currentlyLoading;
}
}
5 changes: 4 additions & 1 deletion src/Stache/Stores/CollectionEntriesStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit c4647ec

Please sign in to comment.