Skip to content
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

Set locales for all domains when enabling multilingual #17733

Merged
merged 2 commits into from
Jul 3, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

In the process of trying to test a possible wordpress regression I found that enabling
mutlilingual on a domain other than domain 1 breaks the site. The reason is that without
only domain 1 is being updated with the new language and locales. Since I'm on domain
2 when I do this I can no longer load any page as the locales value has not been set
and the queries look for option_value.label not option_value.label_us.

Since 'no locale' is no longer valid the locale needs to be set on all sites. Note the
code change is primarily an extraction inn order to only run the table update part once

Before

When enabling multilinngual for one domain 'locales' not updated for other domains and they become unusable (wordpress)

After

civicrm_domain.locales set for all domains to the language being enabled

Technical Details

@colemanw you attempt to address this here - https://github.com/civicrm/civicrm-core/pull/17650/files#diff-fc3e5db5312bd5c376b4b73c3c1be43fR46 but in fact it needs to be all domains get locales set as it is set for the tables that all domains access

Comments

@civibot civibot bot added the master label Jul 2, 2020
@civibot
Copy link

civibot bot commented Jul 2, 2020

(Standard links)

while ($domain->fetch()) {
// skip if the domain is already multi-lang.
if ($domain->locales) {
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make sure that all domains have the same locales?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 I dunno - I think one domain could have less than the others but it gets tricky fast. I decided not to change that edge case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw was thinking that instead maybe domain1 should be treated as global domain see other discussion here #17650

$queries[] = "ALTER TABLE {$table} DROP {$column}";
}
$domain->find();
while ($domain->fetch()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is wonky here... I think some cache is being reset as only first is retrieved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - switched to putting in an array first...

In the process of trying to test a possible wordpress regression I found that enabling
mutlilingual on a domain other than domain 1 breaks the site. The reason is that without
only domain 1 is being updated with the new language and locales. Since I'm on domain
2 when I do this I can no longer load any page as the locales value has not been set
and the queries look for option_value.label not option_value.label_us.

Since 'no locale' is no longer valid the locale needs to be set on all sites. Note the
code change is primarily an extraction inn order to only run the table update part once
@colemanw
Copy link
Member

colemanw commented Jul 2, 2020

So historically domain 1 was treated as the global domain, and I think I messed that up in #17646 and that caused the regression. We've always set the locales value in domain 1 (or technically the first domain since I guess you could delete domain id 1) and my PR changed that. We should probably change it back.

@eileenmcnaughton
Copy link
Contributor Author

@colemanw I'm unclear as to whether what I hit was 'the regression' - since it was a bit edge-case but yeah maybe it did regress. I think this change probably still makes sense even if we do revert the other

@colemanw
Copy link
Member

colemanw commented Jul 2, 2020

I don't want to completely revert #17646 because the performance boost is a big deal and that was the main focus. Reading from the current domain was secondary so I'll just remove that part.

@eileenmcnaughton
Copy link
Contributor Author

Hmm tests pass but no test site :-(

@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 any idea about the lack of test site?

@seamuslee001
Copy link
Contributor

@eileenmcnaughton test site seems to be up here http://core-17733-4dpkx.test-1.civicrm.org:8001/

@seamuslee001
Copy link
Contributor

at least for the latest test

@colemanw
Copy link
Member

colemanw commented Jul 2, 2020

@eileenmcnaughton @seamuslee001 @totten we have multiple discussion threads about this and multiple open PRs.
I've changed my mind about the solution and I think having locales populated consistently for all domains is a good thing.
https://lab.civicrm.org/dev/core/-/issues/1852

@colemanw
Copy link
Member

colemanw commented Jul 2, 2020

This is missing an upgrade step so I added one: #17738

@eileenmcnaughton eileenmcnaughton merged commit f95031c into civicrm:master Jul 3, 2020
@eileenmcnaughton eileenmcnaughton deleted the pvv branch July 3, 2020 04:04
@eileenmcnaughton
Copy link
Contributor Author

This was merged to 5.28 -as was #17646.

It fixed a temporary regression but the regression was not in any rc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants