Problem/Motivation
We have uncovered a bug in Media that recreated deleted Media Types during module install. The scenario is that you install Media module and delete a Media Type. When you install a modules the media types are recreated.
Steps to test or recreate are as follows
- Fresh install of Drupal 8.6.1
- Enable the core media module
- Go to structure->media types and delete one or two (I removed Audio and Video)
- Install a module that provides optional configuration - for example Book (I tried Webforms, the problem was first found with Commerce Shipping)
- Go back to structure->media types and notice the deleted media types are back
Proposed resolution
Fix ConfigInstaller::installOptionalConfig() so that it does not install additional profile configuration that does not depend on the module being installed.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 3002655-17.patch | 5.56 KB | alexpott |
| #17 | 9-17-interdiff.txt | 3.97 KB | alexpott |
| #9 | 3002655-9.patch | 2.76 KB | alexpott |
| #9 | 3002655-9.test-only.patch | 1.75 KB | alexpott |
| #8 | 3002655-8.patch | 1.01 KB | alexpott |
Comments
Comment #2
johnpicozziComment #3
johnpicozziComment #4
nathandentzauI have replicated this and I believe I've found the source of the bundles reappearing. They're being recreated from the optional configuration in the standard install profile. If you delete
/core/profiles/standard/optional/media.type.audio.ymlfile and then delete the audio entity. Then install and enable the webform module (can be any module), the audio bundle is not installed. This seems like an issue with configuration management and unrelated to the media module.Comment #5
nathandentzauComment #6
alexpottooh nice find. I'd guess this is an unintended impact of #2930996: Config installer doesn't install possible installable config
Comment #7
alexpottSo it doesn't happen with any module but from the core modules it does happen with Forum - I think it is any module with optional configuration... so Book causes it too.
Comment #8
alexpottHere's a fix. We only should be checking the profile's optional config for new things to install when we call installOptionalConfig() for the second time during a module install.
This is a major bug. Configuration coming back after being deleted is very confusing and potentially very bad for a site.
Comment #9
alexpottHere's a test that problem.
Comment #10
johnpicozzi@alexpott - I tested this with Patch #8 and it resolves the problem. I will test again with patch 9 later this afternoon. Thanks!
Comment #11
alexpottThe more I think about this I think we have a new critical on our hands. Yes there is a work around - delete the config again - but that would mean you'd have to realise this has happened and you might not. And this type of unexpected change could have consequences for your site.
Comment #12
nathandentzau+1 RTBC on Patch #9. Solution looks good in code as well. Can we set a target for this to be merged in 8.6.x-dev too?
Comment #13
alexpottComment #15
johnpicozzi+1 RTBC on Patch #9 as well! I tested it on a clean install of 8.6.1 as well as within my project and it worked in both.
Comment #16
larowlanis it possible that some dependencies will enable profile provided optional configuration to be required - just not all of it?
Comment #17
alexpott@larowlan yep that can totally occur when installing a new module. For example, when views is installed. We already have tests for this in ConfigInstallProfileOverrideTest - see the entity with the ID
completely_new.I've tried to make what's going on easier to understand by:
This patch is better to review in the full context of the \Drupal\Core\Config\ConfigInstaller::installOptionalConfig().
Here's is the whole function context:
Comment #18
alexpottMaking the title match the issue and sound as critical as this is.
Comment #19
alexpottEdited title for clarity.
Comment #20
alexpottI was wrong about when this was introduced. We caused this in #2513604: Create default responsive image styles - when we added the ability for profiles to provide completely new optional configuration that would be installed when their dependencies were installed.
Comment #21
larowlanLooks good to me, nice cleanup @alexpott - much easier to work out what is going on.
Comment #24
catchCommitted/pushed to 8.7.x and cherry-picked to 8.6.x. Thanks!
Comment #25
catch