dev/core#2232 - Upgrade UI contaminates cache via l10n-js. Consolidate isUpgradeMode(). #19192
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
This patch fixes an upgrade bug (dev/core#2232) where
CachedCiviContainer
has stale data after an upgrade.To do this, it removes an edge-case where two overlapping functions disagree.
Steps to Reproduce
Discussion
The problem is created while running the upgrade GUI (step 5). The GUI sends several HTTP requests (
civicrm/upgrade
,civicrm/upgrade/queue/ajax/runNext
, etc). At the end, there is an HTTP request forcivicrm/ajax/l10n-js/en_US
. Thel10n-js
request creates a flawed copy ofCachedCiviContainer
which is responsible for subsequent errors.This shouldn't happen - there are defensive mechanism which prevent it from happening (e.g. during
civicrm/upgrade
). What makescivicrm/ajax/l10n-js/en_US
different? It turns on the implementation ofisUpgradeMode()
which activates the defensive mechanisms.Before
There are two implementations of
isUpgradeMode()
(viaCRM_Core_Config
andCRM_Utils_System
). They often agree, but not always.Some defensive measures trigger on
CRM_Core_Config::isUpgradeMode()
and others trigger onCRM_Utils_System::isUpgradeMode()
. They often trigger together, but not always.Let's see how these can playout in a few HTTP requests:
civicrm/dashboard
(or any normal page): The functions agree -- it's a regular page, not an upgrade. Therefore:CachedCiviContainer
/CachedExtLoader
(read or write automatically).civicrm/upgrade
: The functions agree -- it's an upgrade. Therefore:CachedCiviContainer
/CachedExtLoader
.civicrm/ajax/l10n-js/en_US
: The functions disagree. In this case:CachedCiviContainer
/CachedExtLoader
(read or write automatically).After
There is one implementation of
isUpgradeMode()
. It may be called through either class (CRM_Core_Config
orCRM_Utils_System
), but the results will always agree.This produces the same appropriate outcome for cases of agreement (1) (2), and it fixes the wonky/mismatched behavior in (3).
Comments
This patch builds on recent work in #19133 and #19141. A few observations:
civicrm/ajax/l10n-js/en_US
in the upgrade UI. (This was pretty hard to find... took 45m of debugging and head-scratching...)CachedCiviContainer
. However, I think this fix is better in two ways: