Problem/Motivation
I have a site that was installed. Then I went ahead and changed its site name. This in turn updated the language config, so the diff looks like so:
--- a/config/common/language.negotiation.yml
+++ b/config/common/language.negotiation.yml
@@ -6,6 +6,7 @@ url:
prefixes:
en: en
nb: ''
+ '': null
This is because the following logic:
if ($saved_config->getName() == 'system.site' && $event->isChanged('default_langcode')) {
Well, the saved config was indeed system.site. But the default_langcode was not changed. Only the system.site.name config was changed. So why is it that $event->isChanged('default_langcode') returns true? Well it's because the $config->original is not equal to the $config->data. Because $config->original is empty, since that is initialized after the config object creates this event (from Config.php):
$this->eventDispatcher->dispatch(new ConfigCrudEvent($this), ConfigEvents::SAVE);
$this->originalData = $this->data;
This is not true if you change the config through the site information config form. But if you import a config change for system.site, naturally a save event for the config will happen, and then $config->original will be empty. It should be possible to write a test for this, but I have at least confirmed it with a clean install on 9.5.x.
Steps to reproduce
- Install Drupal
- Enable language module
- Export the config
- Edit the site name yml file, for example just the name
- Import the config (i used drush)
- Now export the config again (expecting it to be no changes). There is a change in language negotiation
Proposed resolution
Check that there is original config? Or just check that the old default language is not falsy?
Remaining tasks
Decide on an approach. Write tests
User interface changes
none
API changes
none
Data model changes
none
Release notes snippet