Problem/Motivation
I was fighting a strange problem that config schema validation failed due to a string/integer mismatch when saving config in a form.
Turned out that it was a classic Heisenbug, as it only existed because I had a debug($config->get()) call before calling save.
And what happens then is that overriddenData is initialized. Then you save, it casts all the data and saves it correctly. Then comes \Drupal\Core\Config\Development\ConfigSchemaChecker::onConfigSave() and calls $saved_config->get()... and receives the old, overridden data and throws an exception.
Proposed resolution
Move $this->resetOverriddenData(); up, before actually writing the config and invoking the event.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#3 | config-save-overridden-reset-2841651-3.patch | 1.97 KB | Berdir |
#3 | config-save-overridden-reset-2841651-3-test-only.patch | 1.04 KB | Berdir |
Comments
Comment #2
BerdirComment #3
BerdirFailing test and a fix.
Comment #8
borisson_This makes a lot of sense and the patch still applies. It has sufficient testcoverage but it would be helpful to get a review from someone knowledgeable about CMI.
Comment #9
alexpottYep this makes sense. This won't break \Drupal\Core\Config\ConfigCrudEvent::isChanged() and that's what you should be using to determine things have changed in the \Drupal\Core\Config\ConfigEvents::SAVE event.
Comment #10
catch#2806009: Installing a module causes translations to be overwritten is a critical bug about config overrides, haven't tested yet, but this issue or something similar looks like it could be related.
Comment #13
catchCommitted/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!