From 5f69846342dc88018ac3fdf09b052d36f011693b Mon Sep 17 00:00:00 2001 From: Simon Erkelens Date: Tue, 17 Oct 2023 11:55:49 +1300 Subject: [PATCH] Harden the ShowInSearch check --- src/Extensions/DataObjectElasticExtension.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Extensions/DataObjectElasticExtension.php b/src/Extensions/DataObjectElasticExtension.php index 1b6e371..d263dbe 100644 --- a/src/Extensions/DataObjectElasticExtension.php +++ b/src/Extensions/DataObjectElasticExtension.php @@ -124,7 +124,9 @@ public function onAfterWrite() } // @codeCoverageIgnoreStart Elastic during tests isn't fast enough to pick this up properly - if ($this->owner->isChanged('ShowInSearch') && !$this->owner->ShowInSearch) { + if ($this->owner->hasField('ShowInSearch') && + $this->owner->isChanged('ShowInSearch') && + !$this->owner->ShowInSearch) { $this->deleteFromElastic(); } // @codeCoverageIgnoreEnd