Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-13123 - Fix serialization metadata for uf group type field #11472

Merged
merged 1 commit into from
Jan 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion CRM/Core/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2615,6 +2619,7 @@ public static function requireSafeDBName($database) {
* @param array|NULL $value
* @param $serializationType
* @return string|NULL
* @throws \Exception
*/
public static function serializeField($value, $serializationType) {
if ($value === NULL) {
Expand All @@ -2632,6 +2637,12 @@ public static function serializeField($value, $serializationType) {

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.');
}
}

Expand All @@ -2641,6 +2652,7 @@ public static function serializeField($value, $serializationType) {
* @param string|null $value
* @param $serializationType
* @return array|null
* @throws \Exception
*/
public static function unSerializeField($value, $serializationType) {
if ($value === NULL) {
Expand All @@ -2661,6 +2673,12 @@ public static function unSerializeField($value, $serializationType) {

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.');
}
}

Expand Down
8 changes: 4 additions & 4 deletions CRM/Core/DAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/UFGroup.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:2c943baba637124caec29c4aefeb9228)
* (GenCodeChecksum:a33112c87c32c1af77464d08a8715bdb)
*/

/**
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -260,7 +260,7 @@ public static function &fields() {
'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,
Expand All @@ -272,7 +272,7 @@ public static function &fields() {
'entity' => 'UFGroup',
'bao' => 'CRM_Core_BAO_UFGroup',
'localizable' => 0,
'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
'serialize' => self::SERIALIZE_COMMA,
],
'title' => [
'name' => 'title',
Expand Down
4 changes: 2 additions & 2 deletions xml/schema/Core/UFGroup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<type>varchar</type>
<length>255</length>
<import>true</import>
<comment>This column will store a comma separated list of the type(s) of profile fields.</comment>
<serialize>SEPARATOR_TRIMMED</serialize>
<comment>Comma separated list of the type(s) of profile fields.</comment>
<serialize>COMMA</serialize>
<add>2.1</add>
</field>
<field>
Expand Down