Skip to content

Commit

Permalink
NGSTACK-805: handle calling child indexer in delete context
Browse files Browse the repository at this point in the history
  • Loading branch information
pspanja committed Nov 13, 2023
1 parent ad3b4dc commit 52b6b82
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Ibexa\Contracts\Core\Repository\Events\Location\UnhideLocationEvent;
use Ibexa\Contracts\Core\Repository\Events\Trash\RecoverEvent;
use Ibexa\Contracts\Core\Repository\Events\Trash\TrashEvent;
use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException;
use Ibexa\Contracts\Core\Search\Handler as SearchHandler;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

Expand Down Expand Up @@ -116,16 +117,27 @@ public function onRecover(RecoverEvent $event): void
private function handleEvent(int $contentId): void
{
$contentHandler = $this->persistenceHandler->contentHandler();
$contentInfo = $contentHandler->loadContentInfo($contentId);

try {
$contentInfo = $contentHandler->loadContentInfo($contentId);
} catch (NotFoundException) {
return;
}

$contentType = $this->persistenceHandler->contentTypeHandler()->load($contentInfo->contentTypeId);

if ($contentType->identifier !== self::CHILD_CONTENT_TYPE_IDENTIFIER) {
return;
}

$location = $this->persistenceHandler->locationHandler()->load($contentInfo->mainLocationId);
$parentLocation = $this->persistenceHandler->locationHandler()->load($location->parentId);
$parentContentInfo = $contentHandler->loadContentInfo($parentLocation->contentId);
try {
$location = $this->persistenceHandler->locationHandler()->load($contentInfo->mainLocationId);
$parentLocation = $this->persistenceHandler->locationHandler()->load($location->parentId);
$parentContentInfo = $contentHandler->loadContentInfo($parentLocation->contentId);
} catch (NotFoundException) {
return;
}

$parentContentType = $this->persistenceHandler->contentTypeHandler()->load($parentContentInfo->contentTypeId);

if ($parentContentType->identifier !== self::PARENT_CONTENT_TYPE_IDENTIFIER) {
Expand Down

0 comments on commit 52b6b82

Please sign in to comment.