Problem/Motivation
Imagine the following use-case:
You are installing media_entity_instagram and you have a second module, for example thunder_media, which contains media_entity.bundle.instagram.yml as optional config. media_entity.bundle.instagram.yml has a module dependency on media_entity_instagram.
So after the installation, media_entity.bundle.instagram.yml was imported successfully from ConfigInstaller::installOptionalConfig() during ModuleInstaller:install(). So far so good.
Now our thunder_media also contains several field and view/form-mode configs as optional config. These configs don't have a dependency on the module media_entity_instagram but on the config media_entity.bundle.instagram. installOptionalConfig() doesn't pick up the new resolvable dependencies recursively.
Proposed resolution
Let ConfigInstaller::installOptionalConfig() pick up direct and indirect optional configs.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#34 | 2930996-34.patch | 7.78 KB | alexpott |
#34 | 27-34-interdiff.txt | 3.18 KB | alexpott |
#27 | 2930996-27.patch | 7.46 KB | alexpott |
#27 | 25-27-interdiff.txt | 1.68 KB | alexpott |
#25 | 2930996-25.patch | 7.43 KB | alexpott |
Comments
Comment #2
chr.fritschHere is a patch.
Comment #3
chr.fritschComment #5
chr.fritschIt's not only appearing on optional config. If you have an optional configuration based on a config from config/install, it will also not be installed.
Comment #7
alexpottWe need to do some issue archeology to work out why a test for this specific case was added to Drupal\Tests\config\Functional\ConfigOtherModuleTest
Comment #8
alexpottSo the ConfigInstaller used to do this until #2623940: ConfigInstaller tries to install optional config with missing dependencies - reading that issue points towards a better fix. But obviously we need to read it though and determine if we're now breaking something.
No interdiff cause new approach.
Comment #9
alexpott@Berdir pointed out that #8 might cause deleted configuration to suddenly reappear. That would be a problem. We need to add a test for that. #2 might not suffered from this problem. Since we're limiting it only to things with direct dependencies on the new configuration that is created.
Comment #10
alexpottHere's an approach that might satisfy both cases. We need more test coverage though.
Comment #12
chr.fritschI tested the patch with the use-case I provided in the IS and it works fine.
Comment #13
mtodor CreditAttribution: mtodor at Thunder commentedI have tested this additionally. It looks good.
Small nitpick from patch.
Assertion message should be adjusted.
I'm not sure are following cases covered in some of the tests, but they should be:
Since I have fiddled a bit with tests to try single import, I have provided a patch here with mentioned changes. If it's of some use. I'm not sure if that test should be part of the optional configuration test or in import/export tests.
Comment #14
mtodor CreditAttribution: mtodor at Thunder commentedMy uploads are strange in the last comment (#13) - here are correct ones.
Comment #16
alexpottSingle import and full site import explicit don't look in a module's optional configuration so that's okay. What we do need to test is that deleted configuration is not suddenly reimported because of this.
Comment #17
alexpottI've basically reverted #14 since this doesn't add meaningful test coverage. The single import export form doesn't ever touch optional configuration or install anything other than the config object you provide it.
I've have however extended the test coverage to ensure that you can delete a configuration entity provided by a module and then install a module and ensure it does not magically come back again. New optional configuration is only installed if it could not possibly have existed before. I.e. the module being installed has to be in the dependency chain.
Comment #18
chr.fritschThis looks all good to me. Now we also have more test coverage.
And since my patch from #2 was completely reverted, I think I am allowed to mark this RTBC.
Comment #19
chr.fritschSorry, have to kick it back. I tested this patch with Thunder and I found a case where not all possible installable configs get imported.
The corresponding PR in Thunder is https://github.com/BurdaMagazinOrg/thunder-distribution/pull/542
We have to analyze what the exact problem there is and then provide a test for this patch.
Comment #20
alexpottThanks for testing @chr.fritsch nice find. First I'm going to expand the testing to have dependencies of dependencies as looking at https://github.com/BurdaMagazinOrg/thunder-distribution/pull/542 that's the problem.
Comment #21
alexpottThanks thunder tests! So what's happening here is that we need the full configuration graph in order to determine proper dependencies.
Comment #23
alexpottComment #24
alexpottHere's a 8.5.x patch for Thunder testing.
Comment #25
alexpottHere's a test for why we need the full dependency graph and a fix for ViewsKernelTestBase tests. This is needed because of the way it installs configuration out of order and so when we do
$this->installConfig(['system']);
we end up installing some optional views because they depend on system. This populates views data and the overrides from each test didn't take affect. Fun.Comment #26
BerdirI thought we had actually replaced all entity_load() calls, but apparently #2723593: Properly deprecate entity_load() and friends never got in.
Should we at least avoid it in the new calls and use ConfigTest::load()?
word missing? the ... module? ... being installed?
On the plus side, I successfully tested this with two different complex distributions and only had a single problem in a kernel test that was caused by an incorrectly named config file, created #2972003: Verify that the file name matches the ID when installing configuration.
Comment #27
alexpott1. Can we file a follow-up for that? We have to reset the cache every time we load just to be sure we're using up-to-date info.
2. Fixed.
Comment #28
alexpottComment #29
Berdir1. Fine, lets reroll the other issue when this is in. It will conflict anyway. That said, config entities do currently not use the static cache by default, they have to opt-in, and only role is doing that currently. So that cache reset isn't doing anything at the moment, unless we'd opt-in to static caching.
Comment #32
MixologicTestbot Snafu.
Comment #33
catchCan we be more specific than thing?
Should this be configuration entity's dependencies?
Comment #34
alexpott@catch thanks for the review.
Re #1. Turned the sentence around so we didn't have to work out what thing is - it is an extension - either a module or a theme.
Re #2. Yep you're right. I tried to add more detail to help people / myself when I look at this in the future.
As all of the fixes are comments / test assertion text only setting back to rtbc.
Comment #36
catchThis is theoretically just a bug fix, but in practice it could mean unexpected new configuration showing up in profiles and sites under development which feels behaviour-change-ish, so leaving in 8.6.x only for now. Would think about backporting but would we need a change notice for that? (Genuinely not sure).
Comment #37
jhedstromNote that this caused a change in kernel tests where if one specified a module's config to be installed, any optional config for other enabled modules would be installed. This is demonstrated in the Message Digest module's recent fixes: #2981675: Tests are failing on 8.6. The workaround seems fine in that case, but perhaps a change notice is needed? It obviously didn't impact any core tests though.
Comment #38
alexpott@jhedstrom thanks for the report of the issue. Do you feel a CR would have helped you track down the fix? If so it'd be great to add one. I'm not sure of what to write that would be like a change record and inform the people that need to know.
As an aside I feel that KernelTestBase and the way it ignores configuration and module dependencies on configuration install is not really that great.
Comment #39
jhedstromHonestly, probably not. I wouldn't have known what to search for until I found this issue I think.
It's a bit of a mixed bag. It's great to not have to install every single dependency if the tested code doesn't need it, but it does lead to other issues. I think this new approach of installing installable config makes sense, without tipping too far the other way to requiring every dependency to be installed for all kernel tests.
Comment #41
xjmComment #42
xjmThis issue is missing a change record. Can we add one that can be linked in the 8.6.0 release notes? Thanks!
Comment #43
catchAdded a change record.
Comment #44
Amber Himes MatzThanks for the change record. The CR says "This should not require any action from module authors or site administrators." But as @catch pointed out in #36, "in practice it could mean unexpected new configuration showing up in profiles and sites under development".
Under what circumstances would new configuration show up? And what if someone wanted to trigger this? I assume the only way to trigger a recursive installation of config would be to uninstall and re-install the module? Is that correct? (Asking for documentation and tutorial updating's sake.)