Skip to content

Commit

Permalink
Merge pull request #20626 from akosgarai/issue/2645
Browse files Browse the repository at this point in the history
dev/core#2645 Proposed fix for exporting preferred_mail_format field
  • Loading branch information
eileenmcnaughton authored Jun 21, 2021
2 parents be5c39d + b4db5bb commit 40df867
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion CRM/Export/BAO/ExportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,16 @@ public function getSqlColumnDefinition($fieldName, $columnName) {

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
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Export/BAO/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ protected function getBasicSqlColumnDefinition($isContactExport): array {
'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)',
Expand Down Expand Up @@ -2743,7 +2743,7 @@ public function getContributionSqlColumns(): array {
'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)',
Expand Down

0 comments on commit 40df867

Please sign in to comment.