From 3c86d77d1ff599eaf3da4b3e5ef538a4c371f661 Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Tue, 6 Sep 2022 10:29:57 -0400 Subject: [PATCH] allow serialized custom fields to have bigger lengths Before all serialized fields were hard-coded to varchar(255). With this change, they take the given text_length, ensuring we have at least 255 in length. --- CRM/Core/BAO/CustomField.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 90b23a803c..27f0b8c5a5 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -2810,7 +2810,9 @@ WHERE cf.id = %1 AND cg.is_multiple = 1"; } } if ($field->serialize) { - $params['type'] = 'varchar(255)'; + // Ensure length is at least 255, but allow it to go higher. + $text_length = intval($field->text_length) < 255 ? 255 : $field->text_length; + $params['type'] = 'varchar(' . $text_length . ')'; } if (isset($field->default_value)) { $params['default'] = "'{$field->default_value}'"; -- 2.25.1