From dd3ec98b0e58bfb59c6e58e9b2f15657a4a8b763 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 31 Dec 2017 15:01:57 -0500 Subject: [PATCH] CRM-13123 - Fix serialization metadata for uf group type field --- CRM/Core/DAO.php | 20 +++++++++++++++++++- CRM/Core/DAO/UFGroup.php | 8 ++++---- xml/schema/Core/UFGroup.xml | 4 ++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index ef96f42328..d5eab412c1 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -83,7 +83,11 @@ class CRM_Core_DAO extends DB_DataObject { /** * @deprecated format using php serialize() */ - SERIALIZE_PHP = 4; + SERIALIZE_PHP = 4, + /** + * Comma separated string, no quotes, no spaces + */ + SERIALIZE_COMMA = 5; /** * Define entities that shouldn't be created or deleted when creating/ deleting @@ -2615,6 +2619,7 @@ SELECT contact_id * @param array|NULL $value * @param $serializationType * @return string|NULL + * @throws \Exception */ public static function serializeField($value, $serializationType) { if ($value === NULL) { @@ -2632,6 +2637,12 @@ SELECT contact_id case self::SERIALIZE_PHP: return is_array($value) ? serialize($value) : $value; + + case self::SERIALIZE_COMMA: + return is_array($value) ? implode(',', $value) : $value; + + default: + throw new Exception('Unknown serialization method for field.'); } } @@ -2641,6 +2652,7 @@ SELECT contact_id * @param string|null $value * @param $serializationType * @return array|null + * @throws \Exception */ public static function unSerializeField($value, $serializationType) { if ($value === NULL) { @@ -2661,6 +2673,12 @@ SELECT contact_id case self::SERIALIZE_PHP: return strlen($value) ? unserialize($value) : array(); + + case self::SERIALIZE_COMMA: + return explode(',', trim(str_replace(', ', '', $value))); + + default: + throw new Exception('Unknown serialization method for field.'); } } diff --git a/CRM/Core/DAO/UFGroup.php b/CRM/Core/DAO/UFGroup.php index 44300b6f4f..a7c90e8753 100644 --- a/CRM/Core/DAO/UFGroup.php +++ b/CRM/Core/DAO/UFGroup.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/UFGroup.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:2c943baba637124caec29c4aefeb9228) + * (GenCodeChecksum:a33112c87c32c1af77464d08a8715bdb) */ /** @@ -43,7 +43,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { public $is_active; /** - * This column will store a comma separated list of the type(s) of profile fields. + * Comma separated list of the type(s) of profile fields. * * @var string */ @@ -260,7 +260,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { 'name' => 'group_type', 'type' => CRM_Utils_Type::T_STRING, 'title' => ts('Profile Group Type'), - 'description' => 'This column will store a comma separated list of the type(s) of profile fields.', + 'description' => 'Comma separated list of the type(s) of profile fields.', 'maxlength' => 255, 'size' => CRM_Utils_Type::HUGE, 'import' => TRUE, @@ -272,7 +272,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { 'entity' => 'UFGroup', 'bao' => 'CRM_Core_BAO_UFGroup', 'localizable' => 0, - 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED, + 'serialize' => self::SERIALIZE_COMMA, ], 'title' => [ 'name' => 'title', diff --git a/xml/schema/Core/UFGroup.xml b/xml/schema/Core/UFGroup.xml index 69784bf224..e8da1e09dc 100644 --- a/xml/schema/Core/UFGroup.xml +++ b/xml/schema/Core/UFGroup.xml @@ -33,8 +33,8 @@ varchar 255 true - This column will store a comma separated list of the type(s) of profile fields. - SEPARATOR_TRIMMED + Comma separated list of the type(s) of profile fields. + COMMA 2.1 -- 2.25.1