Deal with group update without any parent
authorSamuel Vanhove <samuel@symbiotic.coop>
Thu, 11 May 2023 18:28:40 +0000 (14:28 -0400)
committerSamuel Vanhove <samuel@symbiotic.coop>
Thu, 11 May 2023 18:28:40 +0000 (14:28 -0400)
CRM/Contact/BAO/Group.php

index 138bc13988c5a5c4696c4edd8d6bb4893064fd8e..7c6df47a41dae407733efc83c6a90e72a774d6db 100644 (file)
@@ -372,8 +372,11 @@ 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');
-      $currentParentGroupIDs = explode(',', $parents);
+      if (!empty($parents)) {
+        $currentParentGroupIDs = explode(',', $parents);
+      }
     }
 
     // form the name only if missing: CRM-627