diff --git a/src/Entries/Entry.php b/src/Entries/Entry.php index 1be9722dc9..a31b44e26b 100644 --- a/src/Entries/Entry.php +++ b/src/Entries/Entry.php @@ -78,6 +78,7 @@ class Entry implements Arrayable, ArrayAccess, Augmentable, ContainsQueryableVal protected $withEvents = true; protected $template; protected $layout; + private $computedCallbackCache; private $siteCache; public function __construct() @@ -128,6 +129,7 @@ public function collection($collection = null) }) : null; } + $this->computedCallbackCache = null; $this->collection = $collection instanceof \Statamic\Contracts\Entries\Collection ? $collection->handle() : $collection; return $this; @@ -1019,7 +1021,11 @@ public function getCpSearchResultBadge(): string protected function getComputedCallbacks() { - return Facades\Collection::getComputedCallbacks($this->collection); + if ($this->computedCallbackCache) { + return $this->computedCallbackCache; + } + + return $this->computedCallbackCache = Facades\Collection::getComputedCallbacks($this->collection); } public function __sleep() @@ -1029,6 +1035,6 @@ public function __sleep() $this->slug = $slug($this); } - return array_keys(get_object_vars($this)); + return array_keys(Arr::except(get_object_vars($this), ['computedCallbackCache'])); } }