diff --git a/lib/Container/Compiler/ParentChildIndexingPass.php b/lib/Container/Compiler/ParentChildIndexingPass.php index 0eaeaac5..cb37b0fa 100644 --- a/lib/Container/Compiler/ParentChildIndexingPass.php +++ b/lib/Container/Compiler/ParentChildIndexingPass.php @@ -1,5 +1,7 @@ getDefinition($serviceId); $definition->addTag(self::MessageHandlerTag); } - } -} \ No newline at end of file +} diff --git a/lib/Core/Search/Common/EventSubscriber/ContentEventSubscriber.php b/lib/Core/Search/Common/EventSubscriber/ContentEventSubscriber.php index b6e0ea85..c584bcbf 100644 --- a/lib/Core/Search/Common/EventSubscriber/ContentEventSubscriber.php +++ b/lib/Core/Search/Common/EventSubscriber/ContentEventSubscriber.php @@ -26,11 +26,14 @@ class ContentEventSubscriber implements EventSubscriberInterface { + /** + * @var array + */ private array $parentLocationIdsByContentId = []; + public function __construct( private readonly MessageBusInterface $messageBus, - private readonly LocationHandler $locationHandler, - + private readonly LocationHandler $locationHandler, ) {} public static function getSubscribedEvents(): array @@ -60,6 +63,7 @@ public function onCopyContent(CopyContentEvent $event): void public function onBeforeDeleteContent(BeforeDeleteContentEvent $event): void { $contentLocations = $this->locationHandler->loadLocationsByContent($event->getContentInfo()->id); + try { foreach ($contentLocations as $contentLocation){ $this->parentLocationIdsByContentId[$event->getContentInfo()->id][] = $contentLocation->parentId; @@ -78,6 +82,7 @@ public function onDeleteContent(DeleteContentEvent $event): void $this->parentLocationIdsByContentId[$event->getContentInfo()->id] ?? [], ), ); + unset($this->parentLocationIdsByContentId[$event->getContentInfo()->id]); }