-
-
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
Fix isMultilingual to use static caching and respect current domain #17646
Conversation
(Standard links)
|
Do we need to put any kind of statics flushing in https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/I18n/Schema.php#L96 or https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/I18n/Schema.php#L134? |
I feel like I must be missing something because in the file you linked I see the exact same pattern which seems to completely ignore which domain we're on and just arbitrarily select the first one. It does it here: civicrm-core/CRM/Core/I18n/Schema.php Lines 22 to 24 in 8928896
And here: civicrm-core/CRM/Core/I18n/Schema.php Lines 46 to 48 in 8928896
Am I missing something obvious? These lookups do not pass in domain ID before calling |
@seamuslee001 I've switched this PR to use |
I never used multi-domain, but the fix seems OK (with my limited understanding of the underlying workings of statics). |
Change makes sense to me tests have passed merging as per review from @mlutfy |
Thanks @seamuslee001 I followed up with civicrm/civicrm-drupal#604 |
$domain->find(TRUE); | ||
return (bool) $domain->locales; | ||
$domainId = CRM_Core_Config::domainID(); | ||
return (bool) CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', $domainId, 'locales'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker/revertable thing -- but the function CRM_Core_BAO_Domain::getDomain()
returns a cached instance of the active domain record, eg perhaps:
return (bool) CRM_Core_BAO_Domain::getDomain()->locales;
I'm pretty sure getDomain()
is used in a bunch of other places, so using it would avoid the extra query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@totten the results of CRM_Core_DAO::getFieldValue
are cached in a static var.
I think the real problem with this PR is that it switches from reading domain 1 to reading the current domain, and it was an undocumented rule previously to only store locales data in domain 1. That's the part I want to revert but will have to think it through as the first record in the civicrm_domain
table isn't guaranteed to have id 1
, so it's not as simple as changing $domainId
to 1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaaah, that makes sense.
Overview
This improves the efficiency and accuracy of the
CRM_Core_I18n::isMultilingual
function, preventing a large number of duplicate queries on every request.Before
The function
CRM_Core_I18n::isMultilingual
apparently had two problems:After
Fixed.
Comments
This is going to especially help the efficiency of medatata-heavy operations like APIv4, as
AllCoreTables
calls this function repeatedly.