Problem/Motivation
When changing simple configuration with Config UI enabled, it takes a manual cache rebuild to activate the new config
Steps to reproduce
- Install domain_config_ui
- Configure enabled config forms: system.site: drupal_localhost, two_localhost
- Create 2 nodes
- Set the frontpage to node/1
- Visit the frontpage
- Set the frontpage to node/2
- Notice the frontpage still renders node 1
Proposed resolution
Invalidate the original cache tags when saving simple configuration
Remaining tasks
- Write a merge request
- Review
- Commit
User interface changes
None
API changes
None
Data model changes
None
Issue fork domain-3575434
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mably commentedHi @idebr, I haven't been able to reproduce the problem locally.
Could you try to provide a test that reproduces your problem?
Comment #4
idebr commentedA failing test is available in the merge request
Comment #5
mably commentedThanks @idebr, will have a look at it.
Comment #6
mably commentedRoot cause analysis
When
system.siteis saved through Drupal's normal admin form, core's\Drupal\system\EventSubscriber\ConfigCacheTag::onSave()listens forConfigEvents::SAVEand invalidates theroute_matchandrenderedcache tags. This is what causes theRouteProvider's cached route collections to be cleared, so thatPathProcessorFrontre-resolves/to the new front page path on the next request.However, when domain config overrides are saved via
DomainConfigOverrideEditable::save(), the event dispatched isConfigCollectionEvents::SAVE_IN_COLLECTION— notConfigEvents::SAVE. Core'sConfigCacheTagonly subscribes toConfigEvents::SAVE, so it never sees domain override saves.The consequence is:
/node/1to/uservia the UIDomainConfigOverrideEditable::save()writes the new value correctly and invalidatesconfig:system.site/,RouteProvider::getRouteCollectionForRequest()finds a cache hit (tagged withroute_match, which was not invalidated)/node/1)PathProcessorFront::processInbound()is never called — the RouteProvider skips inbound path processing on cache hitFix
New event subscriber
DomainConfigCacheTagthat listens forDomainConfigOverrideEvents::SAVE_OVERRIDEandDELETE_OVERRIDE, and delegates to core'sConfigCacheTag::onSave()by wrapping the domain override in aConfigCrudEvent. This works becauseDomainConfigOverrideextendsConfigwhich extendsConfigBase, so it's compatible withConfigCrudEvent's constructor.This way we don't duplicate core's logic — any future changes to
ConfigCacheTag::onSave()(e.g. handling additional config names) will automatically apply to domain config overrides too.Changes
New file:
domain_config/src/EventSubscriber/DomainConfigCacheTag.phpModified:
domain_config/domain_config.services.yml— registers the new subscriber with core'ssystem.config_cache_tagservice injected.Modified:
domain_config_ui/tests/src/Functional/DomainConfigUIOverrideTest.php— cleaned up and documentedtestOverrides()with a regression assertion that verifies the front page change takes effect immediately without a manual cache rebuild.Personal Note: it looks like simply firing
ConfigEvents::SAVEcould have some undesired side effects.Comment #8
mably commented