diff --git a/modules/oe_list_pages_link_list_source/src/Plugin/LinkSource/ListPageLinkSource.php b/modules/oe_list_pages_link_list_source/src/Plugin/LinkSource/ListPageLinkSource.php index dd1906b5..eae16c41 100644 --- a/modules/oe_list_pages_link_list_source/src/Plugin/LinkSource/ListPageLinkSource.php +++ b/modules/oe_list_pages_link_list_source/src/Plugin/LinkSource/ListPageLinkSource.php @@ -176,7 +176,15 @@ public function getLinks(int $limit = NULL, int $offset = 0): LinkCollectionInte } foreach ($results->getResultItems() as $item) { - $entity = $item->getOriginalObject()->getEntity(); + try { + // Do not crash the application in case the index still has an item in + // it pointing to an entity that got deleted. + $entity = $item->getOriginalObject()->getEntity(); + } + catch (\Exception $exception) { + continue; + } + /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $this->entityRepository->getTranslationFromContext($entity); /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ diff --git a/src/ListBuilder.php b/src/ListBuilder.php index 2a40af1c..8797c3c6 100644 --- a/src/ListBuilder.php +++ b/src/ListBuilder.php @@ -215,7 +215,13 @@ public function buildList(ListPageConfiguration $configuration): array { // Build the entities. $builder = $this->entityTypeManager->getViewBuilder($configuration->getEntityType()); foreach ($result->getResultItems() as $item) { - $entity = $item->getOriginalObject()->getEntity(); + try { + $entity = $item->getOriginalObject()->getEntity(); + } + catch (\Exception $exception) { + continue; + } + $cache->addCacheableDependency($entity); $entity = $this->entityRepository->getTranslationFromContext($entity); $items[] = $builder->view($entity, $view_mode);