diff --git a/src/Stache/Repositories/GlobalVariablesRepository.php b/src/Stache/Repositories/GlobalVariablesRepository.php index 5d6559d0a79..06d4e7c1705 100644 --- a/src/Stache/Repositories/GlobalVariablesRepository.php +++ b/src/Stache/Repositories/GlobalVariablesRepository.php @@ -7,7 +7,6 @@ use Statamic\Exceptions\GlobalVariablesNotFoundException; use Statamic\Globals\VariablesCollection; use Statamic\Stache\Stache; -use Statamic\Support\Str; class GlobalVariablesRepository implements RepositoryContract { @@ -45,10 +44,13 @@ public function findOrFail($id): Variables public function whereSet($handle): VariablesCollection { - return $this - ->all() - ->filter(fn ($variable) => Str::before($variable->id(), '::') == $handle) - ->values(); + $keys = $this->store + ->index('handle') + ->items() + ->filter(fn ($value) => $value == $handle) + ->keys(); + + return VariablesCollection::make($this->store->getItems($keys)); } public function save($variable) diff --git a/src/Stache/Stores/GlobalVariablesStore.php b/src/Stache/Stores/GlobalVariablesStore.php index 45e65adaeed..3e50d89f933 100644 --- a/src/Stache/Stores/GlobalVariablesStore.php +++ b/src/Stache/Stores/GlobalVariablesStore.php @@ -85,4 +85,11 @@ protected function deleteItemFromDisk($item) $item->globalSet()->removeLocalization($item)->writeFile(); } } + + protected function storeIndexes() + { + return [ + 'handle', + ]; + } }