dev/core#334 Use the current in use collation and character sets when creating new...
authorSeamus Lee <seamuslee001@gmail.com>
Wed, 30 Sep 2020 08:19:58 +0000 (18:19 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Wed, 30 Sep 2020 20:35:17 +0000 (06:35 +1000)
CRM/Core/BAO/CustomField.php

index 55e1b786bbc735b188c96143999afeb7a7ba79b3..41cc7fe7ba8829574cb6dedb35cd89fbc2c64490 100644 (file)
@@ -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',