Exporting in localized civicrm crashes due to long translation for preferred_mail_format varchar(8) field.
Overview
The contact csv export fails on Hungarian crm language, if the preferred_mail_format of the contact is "Both". Chat link
Reproduction steps
- Have a contact with preferred_mail_format = Both.
- On Administer > Localization > Languages, Currency, Locations form (admin/setting/localization) update the Default Language to Hungarian.
- On the Search > Find Contacts form search for the contact with the Both preferred_mail_format.
- Select the contact and choose the Export contacts action (Kapcsolatok exportálása).
- Choose Export PRIMARY fields (Elsődleges mezők exportálása) and Do not merge (Ne egyesítse) on the Export options (Export opciók) screen. Click to continue (Tovább).
- Got an error "DB Error: unknown error".
Current behaviour
Currently it produces an error page instead of the csv. The following lines appeared in the log:
Fatal Error Details = array:3 [
"message" => "DB Error: unknown error"
"code" => null
"exception" => PEAR_Exception {#1254
#cause: DB_Error {#1252
+error_message_prefix: ""
+mode: 16
+level: 1024
+code: -1
+message: "DB Error: unknown error"
+userinfo: """
\n
INSERT INTO civicrm_tmp_d_export_047c092bed1926927fd304aec370141b (`id`, `civicrm_primary_id`, `contact_type`, `contact_sub_type`, `do_not_email`, `do_not_phone`, `do_not_mail`, `do_not_sms`, `do_
not_trade`, `is_opt_out`, `legal_identifier`, `external_identifier`, `sort_name`, `display_name`, `nick_name`, `legal_name`, `image_url`, `preferred_communication_method`, `preferred_language`, `preferred
_mail_format`, `hash`, `contact_source`, `first_name`, `middle_name`, `last_name`, `prefix_id`, `suffix_id`, `formal_title`, `communication_style_id`, `email_greeting_id`, `postal_greeting_id`, `addressee
_id`, `job_title`, `gender_id`, `birth_date`, `is_deceased`, `deceased_date`, `household_name`, `organization_name`, `sic_code`, `user_unique_id`, `current_employer_id`, `contact_is_deleted`, `created_dat
e`, `modified_date`, `addressee`, `email_greeting`, `postal_greeting`, `current_employer`, `location_type`, `address_id`, `street_address`, `street_number`, `street_number_suffix`, `street_name`, `street_
unit`, `supplemental_address_1`, `supplemental_address_2`, `supplemental_address_3`, `city`, `postal_code_suffix`, `postal_code`, `geo_code_1`, `geo_code_2`, `manual_geo_code`, `address_name`, `master_id`
, `county`, `state_province`, `country`, `phone`, `phone_ext`, `phone_type_id`, `phone_type`, `email`, `on_hold`, `is_bulkmail`, `signature_text`, `signature_html`, `im_provider`, `im`, `openid`, `world_r
egion`, `url`, `groups`, `tags`, `notes`)\n
VALUES (1,'1','Organization','','','','','','','','','','Default Organization','Default Organization','','Default Organization','','','','Mindkettő','','','','','','','','','','','','','','','',''
,'','','Default Organization','','','','','','2021-06-09 11:57:52','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','fixme.domainemail@example.org','Nem','','','','',
'','','','','','','')\n
[nativecode=1406 ** Data too long for column 'preferred_mail_format' at row 1]
...
Expected behaviour
The csv has to be generated and has to be downloadable.
Environment information
- CiviCRM: 5.37.1
- CMS: Drupal 8
Comments
As I see, it is the similar issue to this one #2164 (closed) but with a different field. The preferred_mail_format is a varchar(8) field and it is translated before the insertion to the temp table. The translated "Both" is "Mindkettő" in Hungarian so that it doesn't fit to the varchar(8) field. I would like to create a patch for this issue, but i'm not sure how to fix. As far as i see, the column definitions are generated here. An obvious solution could be to change the varchar(n) to text, but i'm not sure that it is the best one.