From 799f3149bf398df1503c38106e4229ab748830d0 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Wed, 30 Sep 2020 18:19:58 +1000 Subject: [PATCH] dev/core#334 Use the current in use collation and character sets when creating new custom value tables --- CRM/Core/BAO/CustomField.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 55e1b786bb..41cc7fe7ba 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1610,10 +1610,15 @@ SELECT $columnName */ public static function defaultCustomTableSchema($params) { // add the id and extends_id + $collation = CRM_Core_BAO_SchemaHandler::getInUseCollation(); + $characterSet = 'utf8'; + if (stripos($collation, 'utf8mb4') !== FALSE) { + $characterSet = 'utf8mb4'; + } $table = [ 'name' => $params['name'], 'is_multiple' => $params['is_multiple'], - 'attributes' => "ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci", + 'attributes' => "ENGINE=InnoDB DEFAULT CHARACTER SET {$characterSet} COLLATE {$collation}", 'fields' => [ [ 'name' => 'id', -- 2.25.1