From b4db5bb7a4a1a244f236f89e8d83ba09086a3464 Mon Sep 17 00:00:00 2001 From: akosgarai Date: Wed, 16 Jun 2021 14:47:28 +0200 Subject: [PATCH] dev/core#2645 Change column definition for preferred_mail_format field A localized value for this field does not fit into the original varchar(8) dev/core#2645 Update testcases --- CRM/Export/BAO/ExportProcessor.php | 11 ++++++++++- tests/phpunit/CRM/Export/BAO/ExportTest.php | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index fff50a8dad..f134e0eaff 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -1464,7 +1464,16 @@ class CRM_Export_BAO_ExportProcessor { case CRM_Utils_Type::T_STRING: if (isset($fieldSpec['maxlength'])) { - return "`$fieldName` varchar({$fieldSpec['maxlength']})"; + // A localized string for the preferred_mail_format does not fit + // into the varchar(8) field. + // @see https://lab.civicrm.org/dev/core/-/issues/2645 + switch ($fieldName) { + case 'preferred_mail_format': + return "`$fieldName` varchar(16)"; + + default: + return "`$fieldName` varchar({$fieldSpec['maxlength']})"; + } } $dataType = $fieldSpec['data_type'] ?? ''; // set the sql columns for custom data diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index 1c8dd99a8b..690bee2797 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -2555,7 +2555,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 'image_url' => '`image_url` longtext', 'preferred_communication_method' => '`preferred_communication_method` varchar(255)', 'preferred_language' => '`preferred_language` varchar(5)', - 'preferred_mail_format' => '`preferred_mail_format` varchar(8)', + 'preferred_mail_format' => '`preferred_mail_format` varchar(16)', 'hash' => '`hash` varchar(32)', 'contact_source' => '`contact_source` varchar(255)', 'first_name' => '`first_name` varchar(64)', @@ -2743,7 +2743,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 'image_url' => '`image_url` longtext', 'preferred_communication_method' => '`preferred_communication_method` varchar(255)', 'preferred_language' => '`preferred_language` varchar(5)', - 'preferred_mail_format' => '`preferred_mail_format` varchar(8)', + 'preferred_mail_format' => '`preferred_mail_format` varchar(16)', 'hash' => '`hash` varchar(32)', 'contact_source' => '`contact_source` varchar(255)', 'first_name' => '`first_name` varchar(64)', -- 2.25.1