From 48a5b640811aedbf93c77614e4855fff305754e8 Mon Sep 17 00:00:00 2001 From: berliner Date: Thu, 19 Oct 2023 13:42:58 +0200 Subject: [PATCH] HPC-9104: Add fail-safe before trying to access a subpage parent entity --- html/modules/custom/ghi_search/ghi_search.module | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/html/modules/custom/ghi_search/ghi_search.module b/html/modules/custom/ghi_search/ghi_search.module index b7ddecd8f..96780d913 100644 --- a/html/modules/custom/ghi_search/ghi_search.module +++ b/html/modules/custom/ghi_search/ghi_search.module @@ -41,8 +41,7 @@ function ghi_search_node_view(array &$build, EntityInterface $entity, EntityView if ($view_mode != 'search_result') { return; } - if ($entity instanceof SubpageNodeInterface) { - $parent = $entity->getParentNode(); + if ($entity instanceof SubpageNodeInterface && $parent = $entity->getParentNode()) { $build['title'][0]['#context']['value'] = $parent->getTitle() . ': ' . $entity->label(); $build['field_entity_reference']['#access'] = FALSE; $build['tags'] = $parent->field_tags->view('search_result');