Skip to content

Commit

Permalink
Add validation to check if object exists before deleting it from index
Browse files Browse the repository at this point in the history
This fixes issue pimcore#277

It checks if the item exists first in the index before trying to delete it
  • Loading branch information
DanielLaranjeira063 authored Jan 15, 2025
1 parent 285d4bc commit 22ea467
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,17 @@ public function doDeleteFromIndex(Concrete $object): void
'id' => $object->getId()
];

$this->logger->info('Deleting data object ' . $object->getId() . ' from es index.');
$this->getClient()->delete($params);
try {
$exists = $this->getClient()->get($params);
} catch (Exception $e){
$exists = false;
$this->logger->debug($e->getMessage());
return;
}
if($exists) {
$this->logger->info('Deleting data object ' . $object->getId() . ' from es index.');
$this->getClient()->delete($params);
}
}

/**
Expand Down

0 comments on commit 22ea467

Please sign in to comment.