From a97265ff29d9be43cc1953bf493dbde7205f7123 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 18 Mar 2025 15:25:58 +0200 Subject: [PATCH] Fix AttributeCollector fails when no group is selected --- .../src/Model/Table/AttributeCollectorsTable.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php index d2861922b..a37f486ba 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php @@ -232,9 +232,10 @@ public function hydrate(int $id, \App\Model\Entity\Petition $petition): bool return in_array($attr['enrollment_attribute']['attribute'], $groupAttributes); })->toArray(); - $groupMemberObj = TableRegistry::getTableLocator()->get('GroupMembers'); - $groupMemberObj->saveAttributeCollectorPetitionAttributes($person->id, $fieldsForGroup); - + if (!empty($fieldsForGroup)) { + $groupMemberObj = TableRegistry::getTableLocator()->get('GroupMembers'); + $groupMemberObj->saveAttributeCollectorPetitionAttributes($person->id, $fieldsForGroup); + } // Save the Date Of Birth. This is the only one that is single valued // and goes under the Person