From 563abc0a06bdff58d9933a36f7f25de16a89b746 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Mon, 4 Mar 2024 19:01:46 +0000 Subject: [PATCH] [4.x] Only retrieve from origin blink cache when its not null (#9661) Co-authored-by: Jason Varga --- src/Data/HasOrigin.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Data/HasOrigin.php b/src/Data/HasOrigin.php index 186299cfad..6f74a37ff9 100644 --- a/src/Data/HasOrigin.php +++ b/src/Data/HasOrigin.php @@ -60,9 +60,17 @@ public function origin($origin = null) { return $this->fluentlyGetOrSet('origin') ->getter(function ($origin) { - return $origin - ? Blink::once($this->getOriginBlinkKey(), fn () => $this->getOriginByString($origin)) - : null; + if (! $origin) { + return null; + } + + if ($found = Blink::get($this->getOriginBlinkKey())) { + return $found; + } + + return tap($this->getOriginByString($origin), function ($found) { + Blink::put($this->getOriginBlinkKey(), $found); + }); }) ->setter(function ($origin) { Blink::forget($this->getOriginBlinkKey());