Skip to content

Commit

Permalink
fix deleted objects are not handled at all
Browse files Browse the repository at this point in the history
  • Loading branch information
rliebi committed Mar 15, 2024
1 parent e7844d3 commit 75b8d0c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/EventListener/Pimcore/ChangeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ public function handle(AssetEvent|DataObjectEvent|DocumentEvent $event): void
return;
}

$this->messageBus->dispatch(new RefreshElement($this->getFreshElement($element)));
try {
$this->messageBus->dispatch(new RefreshElement($this->getFreshElement($element)));
} catch (PimcoreElementNotFoundException) {
// If the element is not found, it has been deleted and we should remove it from index.
$this->messageBus->dispatch(new RefreshElement($element));
}
}

public static function enableListener(): void
Expand All @@ -66,13 +71,13 @@ public static function getSubscribedEvents(): array
return [
AssetEvents::POST_ADD => 'handle',
AssetEvents::POST_UPDATE => 'handle',
AssetEvents::PRE_DELETE => 'handle',
AssetEvents::POST_DELETE => 'handle',
DataObjectEvents::POST_ADD => 'handle',
DataObjectEvents::POST_UPDATE => 'handle',
DataObjectEvents::PRE_DELETE => 'handle',
DataObjectEvents::POST_DELETE => 'handle',
DocumentEvents::POST_ADD => 'handle',
DocumentEvents::POST_UPDATE => 'handle',
DocumentEvents::PRE_DELETE => 'handle',
DocumentEvents::POST_DELETE => 'handle',
];
}

Expand Down

0 comments on commit 75b8d0c

Please sign in to comment.