From 3a69edc7adb80009299857e6ff30eb053ed4c486 Mon Sep 17 00:00:00 2001 From: John Koster Date: Sat, 2 Mar 2024 16:33:26 -0600 Subject: [PATCH 1/2] Update StoresScopedComputedFieldCallbacks.php --- src/Data/StoresScopedComputedFieldCallbacks.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Data/StoresScopedComputedFieldCallbacks.php b/src/Data/StoresScopedComputedFieldCallbacks.php index 7d8025ce9bb..142e9141b0c 100644 --- a/src/Data/StoresScopedComputedFieldCallbacks.php +++ b/src/Data/StoresScopedComputedFieldCallbacks.php @@ -4,6 +4,7 @@ use Closure; use Illuminate\Support\Collection; +use Statamic\Facades\Blink; use Statamic\Support\Arr; use Statamic\Support\Str; @@ -23,8 +24,10 @@ public function computed($scopes, string $field, Closure $callback) public function getComputedCallbacks(string $scope): Collection { - return collect($this->computedFieldCallbacks) - ->filter(fn ($_, $key) => Str::startsWith($key, "{$scope}.")) - ->keyBy(fn ($_, $key) => Str::after($key, "{$scope}.")); + return Blink::once('getComputedCallbacks'.$scope, function () use ($scope) { + return collect($this->computedFieldCallbacks) + ->filter(fn ($_, $key) => Str::startsWith($key, "{$scope}.")) + ->keyBy(fn ($_, $key) => Str::after($key, "{$scope}.")); + }); } } From e01f7bb458772c702fbcfc694e149bfc1b71ad1f Mon Sep 17 00:00:00 2001 From: John Koster Date: Tue, 12 Mar 2024 19:31:26 -0500 Subject: [PATCH 2/2] Prefix getComputedCallbacks blink key with class to prevent re-use issues --- src/Data/StoresScopedComputedFieldCallbacks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/StoresScopedComputedFieldCallbacks.php b/src/Data/StoresScopedComputedFieldCallbacks.php index 142e9141b0c..808d1bf106d 100644 --- a/src/Data/StoresScopedComputedFieldCallbacks.php +++ b/src/Data/StoresScopedComputedFieldCallbacks.php @@ -24,7 +24,7 @@ public function computed($scopes, string $field, Closure $callback) public function getComputedCallbacks(string $scope): Collection { - return Blink::once('getComputedCallbacks'.$scope, function () use ($scope) { + return Blink::once(__CLASS__.'::getComputedCallbacks'.$scope, function () use ($scope) { return collect($this->computedFieldCallbacks) ->filter(fn ($_, $key) => Str::startsWith($key, "{$scope}.")) ->keyBy(fn ($_, $key) => Str::after($key, "{$scope}."));