From 96cacd7c6deb5d93a761213af1855ed48db2a0ec Mon Sep 17 00:00:00 2001 From: Mateusz Deszert-Klosowski Date: Thu, 26 Sep 2024 08:57:00 +0200 Subject: [PATCH] Fix for refreshing deleted resource --- src/Refresher/ResourceRefresher.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Refresher/ResourceRefresher.php b/src/Refresher/ResourceRefresher.php index 07494d48..bc0a6dce 100644 --- a/src/Refresher/ResourceRefresher.php +++ b/src/Refresher/ResourceRefresher.php @@ -19,7 +19,9 @@ final class ResourceRefresher implements ResourceRefresherInterface { public function refresh(ResourceInterface $resource, ObjectPersisterInterface $objectPersister): void { - $objectPersister->deleteById($resource->getId()); - $objectPersister->replaceOne($resource); + if ($resource->getId()) { + $objectPersister->deleteById($resource->getId()); + $objectPersister->replaceOne($resource); + } } }