Remove wasteful double-caching of settings metadata #14259
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Improves efficiency by removing redundant caching and repeated calls to the same hook.
Before
Settings metadata was being cached once per domain and one extra time for good measure.
hook_civicrm_alterSettingsMetaData()
was invoked even when fetching cached data, even though the hook-altered data was stored in the cache.After
Settings metadata cached once per domain.
hook_civicrm_alterSettingsMetaData()
is invoked only once per domain; as its results were being cached anyway I don't see the need to invoke it repeatedly.Technical details
Instead of firing
hook_civicrm_alterSettingsMetaData()
once and then caching the results, the hook was fired once, cached, and then fired again every time metadata was loaded (potentially hundreds of times per request). In addition to being inefficient this could cause weird bugs since the data already altered by hook was then being passed into the hook to be altered again; depending on how the hook implementation was written this could give unexpected results.