(dev/core#1846) Ensure that the Container
is always fresh when upgrading
#17740
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
CiviCRM has a "container cache" (
CachedCiviContainer.XXX.php
) to organize the loading of various resources.Generally, the "container cache" should auto-update whenever the corresponding CiviCRM code changes. However, there still appear to be some scenarios where it doesn't - which can lead to failures. For example, this comment reported an upgrade failure involving the resource
ContactSchemaMapSubscriber
-- that was removed in 5.27. The failure message implies that a stale copy ofCachedCiviContainer.XXX.php
retained a reference toContactSchemaMapSubscriber
.Before
When upgrading, the
CachedCiviContainer.XXX.php
performs its regular freshness check. This ordinarily causes it to refreshCachedCiviContainer.XXX.php
. However, if (for any reason), the freshness check doesn't work - then it may complain.After
When upgrading, the cache filename
CachedCiviContainer.XXX.php
changes (ie by choosing a different value ofXXX
). It will not read the old file - and it will only create a new/fresh file that matches the current version.Comments
I could not reproduce the reported error organically with an upgrade from 5.26 to 5.27. To reproduce it, I had to use this procedure:
civicrm.settings.php
to setdefine('CIVICRM_CONTAINER_CACHE', 'always');
In theory, the error might also happen if you upgrade from an older/buggier version - for example, in v5.24, it had a bug which put incomplete metadata into
CachedCiviContainer.XXX.php
. The bug in v5.24 could prevent it from rebuilding the file automatically on v5.27.With the change in this patch, someone performing an upgrade should get a clean
CachedCiviContainer
even if the settings are weird (CIVICRM_CONTAINER_CACHE
) and even if the previously-installed version had a bug.