civicrm / org.civicrm.flexmailer

FlexMailer is now part of civicrm-core. Please see the link below for how to upgrade.
https://civicrm.org/extensions/flexmailer
Other
5 stars 22 forks source link

double underscore "__fr_CA" db replacement (i18n) #4

Closed samuelsov closed 7 years ago

samuelsov commented 7 years ago

When using Flexmailer with Mosaico in a multilingual settings, there is some db error like :

(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => exceptionHandler
        )

    [code] => -18
    [message] => DB Error: no such table
    [mode] => 16
    [debug_info] => 
SELECT  v.label as label ,v.value as value
FROM   civicrm_option_value__en_US v,
       civicrm_option_group__en_US g
WHERE  v.option_group_id = g.id
  AND  g.name            = 'activity_type'
  AND  v.is_active       = 1
  AND  g.is_active       = 1
  AND  v.name     = 'Bulk Email'
 [nativecode=1146 ** Table 'example.civicrm_option_value__en_US' doesn't exist]
    [type] => DB_Error
    [user_info] => 
SELECT  v.label as label ,v.value as value
FROM   civicrm_option_value__en_US v,
       civicrm_option_group__en_US g
WHERE  v.option_group_id = g.id
  AND  g.name            = 'activity_type'
  AND  v.is_active       = 1
  AND  g.is_active       = 1
  AND  v.name     = 'Bulk Email'
 [nativecode=1146 ** Table 'example.civicrm_option_value__en_US' doesn't exist]
    [to_string] => [db_error: message="DB Error: no such table" code=-18 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="
SELECT  v.label as label ,v.value as value
FROM   civicrm_option_value__en_US v,
       civicrm_option_group__en_US g
WHERE  v.option_group_id = g.id
  AND  g.name            = 'activity_type'
  AND  v.is_active       = 1
  AND  g.is_active       = 1
  AND  v.name     = 'Bulk Email'
 [nativecode=1146 ** Table 'example.civicrm_option_value__en_US' doesn't exist]"]
)

The table name is replaced by its i18n equivalent but use two underscore instead of one.

samuelsov commented 7 years ago

I think the problem is that there is a confusion between dbLocale which should contain the underscore and tsLocale which should not.

We can solve this problem by replacing :
$swapLang = \CRM_Utils_AutoClean::swap('global://dbLocale?getter', 'call://i18n/setLocale', $mailing->language); to :
$swapLang = \CRM_Utils_AutoClean::swap('global://tsLocale?getter', 'call://i18n/setLocale', $mailing->language);

But we might want to use getLocale instead of the global variable ? Not sure how CRM_Utils_AutoClean::swap is working though...

totten commented 7 years ago

PR merged! 👍