Problem/Motivation
Follow-up to #2655104: List unmet configuration dependencies instead of just failing, introduce a notice caused by array_unique.
Notice: Array to string conversion in Drupal\Core\Config\ConfigInstaller->checkConfigurationToInstall() (line 460 of core/lib/Drupal/Core/Config/ConfigInstaller.php).
if (!empty($invalid_default_config)) {
- throw UnmetDependenciesException::create($name, $invalid_default_config);
+ throw UnmetDependenciesException::create($name, array_unique($missing_dependencies));
}Proposed resolution
- Remove array_unique. If same dependency is missing in different configurations, display all of them. We shouldn't choose to display only one of them.
- Use the
SORT_REGULARflag, but this will display some duplicate dependencies. - Remove array_unique and replace logic in formatConfigObjectList() or before array_unique call and formatConfigObjectList().
Remaining tasks
Define the best choiceCreate patchCreate tests- Review patch
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | 2816307-24.patch | 4.79 KB | himanshu-dixit |
| #24 | interdiff-2816307-22-24.txt | 1.74 KB | himanshu-dixit |
| #22 | interdiff-2816307-18-21.txt | 1.74 KB | himanshu-dixit |
| #22 | 2816307-21.patch | 4.79 KB | himanshu-dixit |
| #18 | interdiff_13-18.txt | 1.84 KB | jofitz |
Comments
Comment #2
goz commentedMy preferred solution is 1.
Attach a patch for it.
Comment #3
dawehnerWhat about introducing some small test to it?
Comment #4
goz commentedRight, but if i can have feedbacks about 3 proposed solutions (or another) before writing tests
Comment #5
james.williams@GoZ I think you're taking the right approach here. Someone else wiser than me might think otherwise, but I agree with you. The
array_unique()usage looks to be left over from an early version of the other issue's patch in #2655104-13: List unmet configuration dependencies instead of just failing, which dealt with a flat array of dependencies, but it later changed into a multi-dimensional array which would cause this notice.Comment #6
goz commentedComment #7
goz commentedHere is two patch, one should failed. It's unique purpose is to show the current code is wrong.
The second patch is the good one with tests + fix.
Comment #9
goz commentedComment #10
james.williamsLooks good to me and the tests pass/fail as they should - thanks!
Comment #11
catchHmm I think I would have gone for option 2 or 3 here to reduce the duplicates. Why not just use SORT_REGULAR to at least have fewer dups?
Comment #12
goz commentedComment #13
james.williamsHere's a new patch then that uses the sort flag with array_unique(). :-)
Comment #14
goz commentedI don't think 2 or 3 are a good solution.
Error message should be as exhaustive as possible. With array_unique, we miss information about missing dependencies for config_test.dynamic.yet_another_module_test_with_dependency config (even if they are the sames as config_test.dynamic.other_module_test_with_dependency, we should known this config has missing dependencies to).
I don't see other methods, except grouping by dependencies instead of config to have fewer dups.
Comment #16
james.williamsSorry patch #13 was rushed -- the change to use the sort flag was implemented, but I didn't change the test, which of course now needs to test for a different message.
Comment #18
jofitzCorrected the test.
Comment #19
claudiu.cristeaThis is new code, we should not use deprecated assert methods: s/assertEqual/assertEquals.
Comment #20
himanshu-dixit commentedIMHO we need to clean full core to remove the deprecated asset methods. There are many places where i saw that there are many places where these assert methods are used.
Let's create a follow up for this. What do you think?
Comment #21
james.williams@himanshu-dixit it would need doing at some point, yes, though it needs to be in the right branch to for the BC policy.
@claudiu.cristea Thanks, good spot. Putting back to needs work then.
Comment #22
himanshu-dixit commentedIf we are going to fix it for this issue. Here is the patch,
UPDATE: Sorry, didn't noticed #21 was posted before i was submitting the patch.
Comment #23
dawehnerNote:
assertEqualsshould get the expected value as first parameter.Comment #24
himanshu-dixit commented@dawehner Thanks for catching this, i forgot about it KernelTestBase. Here is the new patch, do you think this can get RTBC?
Comment #25
claudiu.cristeaRTBC if passes.
Comment #28
catchCommitted/pushed to 8.4.x and cherry-picked to 8.3.x, thanks! Untagging as string change since there's no string change here.
Comment #29
himanshu-dixit commentedAttribution Added