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

(dev/core#1846) Ensure that the Container is always fresh when upgrading #17740

Merged
merged 1 commit into from
Jul 3, 2020

Conversation

totten
Copy link
Member

@totten totten commented Jul 2, 2020

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 of CachedCiviContainer.XXX.php retained a reference to ContactSchemaMapSubscriber.

Error: Class 'Civi\Api4\Event\Subscriber\ContactSchemaMapSubscriber' not found in
CachedCiviContainer->getCiviApi4EventSubscriberContactschemamapsubscriberService()
(line 426 of /home/webadmin/public_html/XXX/sites/default/files/civicrm/templates_/
CachedCiviContainer.XXX3a1bd2c1b046653ce2f7b8bfb2a5.php).

Before

When upgrading, the CachedCiviContainer.XXX.php performs its regular freshness check. This ordinarily causes it to refresh CachedCiviContainer.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 of XXX). 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:

  • Install v5.26
  • Edit civicrm.settings.php to set define('CIVICRM_CONTAINER_CACHE', 'always');
  • Switch to v5.27

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.

…rsion number

Before
------

If you load a new version of the CiviCRM codebase, then a freshness check
should cause the container cache to reset automatically (based on the fact
that various files have new timestamps).

However, it's possible that some kind of bug or omission prevents this from working.
Many developers won't notice such a bug because they're obsessive-compulsive
about clearing caches anyway.

After
-----

If you load a new version of the CiviCRM codebase, then it should use a new
container cache - regardless of how well the freshness check works.
@civibot
Copy link

civibot bot commented Jul 2, 2020

(Standard links)

@civibot civibot bot added the 5.27 label Jul 2, 2020
@totten totten changed the title (dev/core#1846) Container, ClassLoader Caches - Separate caches by version number (dev/core#1846) Ensure that the Container is always fresh when upgrading Jul 3, 2020
@eileenmcnaughton eileenmcnaughton merged commit 00486d0 into civicrm:5.27 Jul 3, 2020
@totten totten deleted the 5.27-container-cache branch July 3, 2020 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants