From 75abd6e269945e4efee8e038bbae37bb7298590e Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 30 Oct 2024 12:01:52 +0000 Subject: [PATCH 1/2] Fix errors on creating new entries --- src/Typesense/Index.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Typesense/Index.php b/src/Typesense/Index.php index 028f9e8..aa6c723 100644 --- a/src/Typesense/Index.php +++ b/src/Typesense/Index.php @@ -9,6 +9,7 @@ use Statamic\Support\Arr; use Typesense\Client; use Typesense\Exceptions\TypesenseClientError; +use Typesense\Exceptions\ObjectNotFound; class Index extends BaseIndex { @@ -53,7 +54,11 @@ public function insertMultiple($documents) public function delete($document) { - $this->getOrCreateIndex()->documents[$document->getSearchReference()]?->delete(); + try { + $this->getOrCreateIndex()->documents[$document->getSearchReference()]?->delete(); + } catch (ObjectNotFound $e) { + // do nothing, this just prevents errors bubbling up when the document doesnt exist + } } public function exists() From 9690f690a63c0f74c32cb245da648bf1b6da4c17 Mon Sep 17 00:00:00 2001 From: ryanmitchell Date: Wed, 30 Oct 2024 12:02:12 +0000 Subject: [PATCH 2/2] Fix styling --- src/Typesense/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Typesense/Index.php b/src/Typesense/Index.php index aa6c723..474da36 100644 --- a/src/Typesense/Index.php +++ b/src/Typesense/Index.php @@ -8,8 +8,8 @@ use Statamic\Search\Index as BaseIndex; use Statamic\Support\Arr; use Typesense\Client; -use Typesense\Exceptions\TypesenseClientError; use Typesense\Exceptions\ObjectNotFound; +use Typesense\Exceptions\TypesenseClientError; class Index extends BaseIndex {