-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(dev/core#3979) Localization - Assign a locale for UF during negotiation #24996
Conversation
Note: On current D7, this doesn't actually reproduce the message because `bootstrap.inc` redirects it ``` function _drupal_bootstrap_configuration() { // Set the Drupal custom error handler. set_error_handler('_drupal_error_handler'); set_exception_handler('_drupal_exception_handler'); ``` But if you comment out `set_error_handler()`, then it does. And I presume it would on D8+...
(Standard links)
|
I don't know about drush but for drupal 7 |
Looks like that test passes now. Aside: As someone who hadn't used
|
Thanks! Of course I don't seem to have recorded where this came up which would have been helpful. I'll put merge ready and check my notes. |
I'm not sure if there's a common scenario, and you probably only had a warning. (At least, that's what tdev/core#3979 emphasized.) Hypothetically, this probably fixes a bug in the following scenario:
|
The situation was I was trying to debug why cdntaxreceipts wasn't translating. The rest of that story is a bit irrelevant here but there's a part where it calls setLocale. It turned out this null business wasn't the issue, but I obviously felt it worth noting, and it must have made me wonder why it wasn't coming up in unit tests which call setLocale plenty. Where it might come up is the way drupal does that language url redirection on its side, but I don't use that anywhere. I.e. maybe it would end up reverting to english in some spots. And maybe a question for another day is why does it even try to set the cms lang - possibly as you've noted for cms modules implementing civi things? Except also as noted it doesn't even try for non-drupal. So anyway this seems to work fine. |
Overview
For: https://lab.civicrm.org/dev/core/-/issues/3979
Related: https://lab.civicrm.org/dev/translation/-/issues/78
Before
If you make an APIv4 call with
setLanguage('en_NZ')
, it negotiates an active locale for various layers (Civi'stsLocale
anddbLocale
, the currency-formatter, and so on). However, it neglects to choose a locale for the UF.Consequently, it calls
CRM_Utils_System::setUFLocale(NULL)
which produces PHP warnings in some environments (eg PHP 8.1 and D9(?)).After
If you make an APIv4 call with
setLanguage('en_NZ')
, it negotiates an active locale. It now chooses the UF locale as well.Consequently, it calls
CRM_Utils_System::setUFLocale('en_NZ')
which does not produce those PHP warnings.Comments
The implementation is a bit wrong, but I suspect it's not consequential. Want to figure out testing before we geeking out on that.
The test will probably fail because the test sites don't have localization data for UFs. @demeritcowboy, is there some magic
drush
incantation to get the localization data for a couple example locales? (Some Civi tests usede_DE
andfr_FR
, sode
andfr
might be handy...)