From: Sandor Semsey Date: Fri, 20 Oct 2023 12:49:29 +0000 (+0200) Subject: CRM_Contact_BAO_Contact::add handle serialized contact_sub_type also X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cd33c6a70f1605d7bd7dff0c515592ff4eb928e7;p=civicrm-core.git CRM_Contact_BAO_Contact::add handle serialized contact_sub_type also Co-authored-by: colemanw --- diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index a9c772dc41..fc3435e30f 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -119,8 +119,10 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact implements Civi\Co // CRM-7925 throw new CRM_Core_Exception(ts('The Contact Sub Type does not match the Contact type for this record')); } - // Cast to array as serialization in CRM_Core_DAO::copyValues() will happen only if it is an array. - $params['contact_sub_type'] = (array) ($params['contact_sub_type']); + // Ensure value is an array so it can be handled properly by `copyValues()` + if (is_string($params['contact_sub_type'])) { + $params['contact_sub_type'] = CRM_Core_DAO::unSerializeField($params['contact_sub_type'], self::fields()['contact_sub_type']['serialize']); + } } }