Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently, if upon enabling a module, a configuration has unfulfilled dependencies an UnmetDependenciesException is thrown, hinting you at which YAML file to look, but not which element caused the exception:
Configuration objects (block.block.foo) provided by some_module have unmet dependencies
The patch changes this behaviour by adding the list of unmet dependencies to the output:
Configuration objects provided by some_module have unmet dependencies: block.block.foo (some.missing.dependency, another.missing.dependency)
Comment | File | Size | Author |
---|---|---|---|
#56 | interdiff.txt | 1.5 KB | dawehner |
#56 | 2655104-56.patch | 12.34 KB | dawehner |
#53 | interdiff.txt | 2.5 KB | dawehner |
#53 | 2655104-53.patch | 12.51 KB | dawehner |
#51 | interdiff.txt | 3.46 KB | dawehner |
Comments
Comment #2
smk-ka CreditAttribution: smk-ka commentedComment #6
snufkin CreditAttribution: snufkin commentedThis patch just saved a few hours of debugging time for me, works fine with 8.0.5, thanks!
Comment #8
chr.fritschPatch works fine. Now lets try to fix the tests
Comment #9
chr.fritschComment #10
dawehnerThis would be such a nice feature!
Is there any way to do that without adding state to the class? Can't we do something with return values?
Comment #13
phenaproximaAn alternate approach that does not add state to ConfigInstaller (although I did need to use an "out" param, which sucks, but ConfigInstaller is structured in a way that left me no other obvious choice). This patch does change a few protected methods, which according to @berdir might not constitute a BC break.
Ideally the UnmetDependenciesException would be formatted in such a way that we could say which dependents had which unmet dependencies, but this is still an improvement.
Comment #15
bschilt CreditAttribution: bschilt at Acquia commentedThe patch in #13 applied cleanly but didn't seem to do anything. The unmet dependency message remained default. I did install the patch from #8 and was able to see the missing/unmet dependency.
Comment #16
mpotter CreditAttribution: mpotter at Phase2 commentedSame here. The patch in #13 didn't work, but using the patch from #8 is still good in v8.1
Comment #17
gclicon CreditAttribution: gclicon at Achieve Internet commentedI updated the patch in #8 agains 8.2.x. I included minor code style updates and updated the ConfigInstallTest to account for the new message format and the new ConfigObjects array.
Comment #18
gclicon CreditAttribution: gclicon at Achieve Internet commentedComment #20
gclicon CreditAttribution: gclicon at Achieve Internet commentedAnother update to the patch. This time it includes update to ConfigInstallProfileUnmetDependenciesTest and to ConfigInstallWebTest.
Comment #21
vasiketested the latest (#20) on 8.1.3 and it worked - it helped to find the right unmet dependencies.
Thanks
Comment #22
JamesK CreditAttribution: JamesK at Advisor Websites commentedNice work gclicon getting this polished.
Comment #24
gclicon CreditAttribution: gclicon at Achieve Internet commentedInitial pass at re-rolling the patch so that it actually applies. The test will need to be updated again, but this should atleast allow the patch to apply while I clean up the tests again.
Comment #25
gclicon CreditAttribution: gclicon at Achieve Internet commentedComment #26
gclicon CreditAttribution: gclicon at Achieve Internet commentedLooks like I was mistaken. The patch applied properly and passed testing.
Comment #27
chr.fritschWorks fine for me as well. Back to RTBC
Comment #28
chr.fritschI've just fixed coding style issues
Comment #29
xjmThis will be an excellent improvement!
It would be helpful to have screenshots of manually testing this and showing how the unmet dependencies are displayed in the UI.
I don't think we should be removing these assertions; if we need to update the message to match, that makes sense, but we should still test it.
Comment #30
jhedstromI'll add those assertions back and take some screenshots.
I think this is a task (or potentially even a DX bug), so it might be eligible for backport to 8.1.x.
Comment #31
jhedstromI manually removed a config dependency in the workbench moderation module for these.
Here's screenshots of the UI.
Before
After
And here's screenshots of a
drush en -y workbench_moderation
Before
After
Regarding the assertions, they aren't so much removed as re-worked:
What I'm not sure of is why the
config_other_module_config_config_test.weitd_simple_config
would no longer be part of the assertion?Comment #32
dawehnerIt is super sad that we didn't continued with the approach in #13 as its IMHO the much better way to solve that. I could imagine that the introduction of state in here will bite us one day.
Can we at least reset the values of the missing variable when we throw the exception? This at least let's one potential bug disappear, which exists when you reevaluate this function with some different state of the underneath.
Comment #33
jhedstromIf somebody can get the approach from #13 working, it seems better to me to also not add state into the config installer if not needed.
Comment #34
jhedstromThis is a return to the approach in #13. It is a reroll, combined with test-changes, and exception language changes from the above patches.
The screenshots in #31 remain unchanged with this approach.
Comment #35
jhedstromThis is the reason #13 wasn't working--the
use
statement for closures must explicitly declare variables that should be passed by reference.Comment #37
chx CreditAttribution: chx at Smartsheet commentedI love functional style perhaps more than I should but isn't this a case where PHP's asinine syntax goes against using that style? Is there a good reason to do this?
Comment #38
chx CreditAttribution: chx at Smartsheet commentedDid I miss (ahem) something?
Comment #39
jhedstromThanks @chx, that approach is much more readable I think.
Agreed.
This fixes the remaining test, and updates some code docs in the exception.
Comment #41
dawehnerIt really looks like this does a copy of the existing array. Do we actually need this? In case we do, what about writing a comment?
Comment #42
jhedstromre #41: good find! No need to copy the array there.
Comment #43
dawehnerThis looks great for me.
I'm so looking forward to see this in. IMHO this helps a lot of people out there.
Can be totally fixed on commit: unnecessary change.
Comment #44
alexpottI ponder if we should just return $missing_dependencies instead. But this approach is more BC compatible so I guess this is fine. Perhaps we should file a 9.x issue to change this. Or maybe we consider this change acceptable for a minor release - which this has to be because of the string changes. I'll ping catch to ask.
I think we should change everything to % - these are all placeholdered. I probably used @extension originally because we shouldn't placeholder in the actual exception message.
Comment #46
jhedstromI'm not seeing the test failures at all...back to RTBC.
Comment #47
dawehnerWell yeah, I think the hope is to get the task in at least for 8.2.x
Comment #48
alexpott@dawehner it can't go in 8.2.x because of the string changes and it is a task.
Back to needs work for #44.
I discussed with @catch are he's okay with changing the return value of findDefaultConfigWithUnmetDependencies
Comment #49
dawehnerSure, let's change that.
Comment #51
dawehnerLet's fix the failures.
Comment #52
claudiu.cristeaSeems to me that $invalid_default_config items are also the keys of $missing_dependencies. I think we can rely only on $missing_dependencies. Also that indexed array with 2 items doesn't represent a list - semantically it's more an associative array.
If we already touched this line, let's drop the deprecated SafeMarkup and replace it with the proper class. Or just use double quote string embedding.
Unrelated.
Comment #53
dawehnerThank you for your review @claudiu.cristea
I agree with you, BUT, I think the level of BC breaking would be bigger by that. Now potentially subclasses break, but there is at least an easy way to fix it. When you drop
$invalid_default_config
it would be much harder for them to get their original functionality back. Its some consideration which could be made here.I fixed the other bits.
Comment #54
cilefen CreditAttribution: cilefen commentedComment #55
alexpottLooking good - one minor thing.
No longer need the
array &...
Comment #56
dawehnerOh yeah, that's true.
Comment #57
claudiu.cristeaGood, then
Comment #58
alexpottCommitted efcf521 and pushed to 8.3.x. Thanks!
Comment #61
BerdirIt looks like this resulted in a behavior change that resulted in test fails in the sharemessage project: #2817923: Demo tests are falling on HEAD. Can someone comment there if this an expected or unexpected change? I have no problem with changing the test and it should also be backwards compatible, but this could be an unexpected side effect.
Comment #62
james.williams CreditAttribution: james.williams at ComputerMinds commentedI've found an issue with this change. Follow-up issue here: #2831816: Only first set of configuration dependencies is checked on installation.
Comment #63
blacklabel_tom CreditAttribution: blacklabel_tom at Edo commentedThis patch applies cleanly to the 8.2.5 release.
Cheers
Tom