From f8ecafe9f9f374119bb6e4e1edc92971ffb94065 Mon Sep 17 00:00:00 2001 From: Samuel Vanhove Date: Wed, 17 May 2023 09:53:41 -0400 Subject: [PATCH] Non standard behavior when not providing parents + simplification --- CRM/Contact/BAO/Group.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 7c6df47a41..6ff6d55533 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -372,11 +372,8 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } // get current parents for removal if not in the list anymore - $currentParentGroupIDs = []; $parents = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $params['id'], 'parents'); - if (!empty($parents)) { - $currentParentGroupIDs = explode(',', $parents); - } + $currentParentGroupIDs = $parents ? explode(',', $parents) : []; } // form the name only if missing: CRM-627 @@ -451,7 +448,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } // first deal with removed parents - if (!empty($params['id']) && !empty($currentParentGroupIDs)) { + if (array_key_exists('parents', $params) && !empty($currentParentGroupIDs)) { foreach ($currentParentGroupIDs as $parentGroupId) { // no more parents or not in the new list, let's remove if (empty($params['parents']) || !in_array($parentGroupId, $params['parents'])) { -- 2.25.1