From b4e8c8d58fa8b71cbd6afa9f50510bb1f9f5f8f4 Mon Sep 17 00:00:00 2001 From: Adrian Bateman Date: Wed, 25 Sep 2024 23:33:29 +0100 Subject: [PATCH] fix(LP-90): Check fields exist --- src/Commands/ContentOwnership.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Commands/ContentOwnership.php b/src/Commands/ContentOwnership.php index f4ab896..c798755 100644 --- a/src/Commands/ContentOwnership.php +++ b/src/Commands/ContentOwnership.php @@ -92,11 +92,17 @@ public function addServiceContactsToNodes() { foreach ($node_storage->loadMultiple($ids) as $node) { $content_owners = []; // Combine content owners of both types without duplication. - foreach ($node->get('field_content_owner')->referencedEntities() as $entity) { - $content_owners[$entity->id()] = $entity; + if ($node->hasField('field_content_owner')) { + foreach ($node->get('field_content_owner') + ->referencedEntities() as $entity) { + $content_owners[$entity->id()] = $entity; + } } - foreach ($node->get('field_content_sme')->referencedEntities() as $entity) { - $content_owners[$entity->id()] = $entity; + if ($node->hasField('field_content_sme')) { + foreach ($node->get('field_content_sme') + ->referencedEntities() as $entity) { + $content_owners[$entity->id()] = $entity; + } } $count = 0;