Problem/Motivation
Module list form does some dependency calculations to ascertain whether to disable the checkbox for enabling a module.
To pave the way for #3005229: Provide optional support for using composer.json for dependency metadata we should refactor it a bit.
Proposed resolution
At the moment we have a hunk with an if/elseif/elseif/elseif/else ie that's three elseifs.
Once we get to #3005229: Provide optional support for using composer.json for dependency metadata we'll need another for the different path between the composer and BC layer. One elseif is too many, and four is just plain ugmo.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3053832-refactor-module-list-form-14.patch | 12.96 KB | larowlan |
| #14 | interdiff-b8c97c.txt | 3.44 KB | larowlan |
| #6 | Screen Shot 2019-05-17 at 3.01.18 pm.png | 164.63 KB | larowlan |
| #5 | interdiff-06a38d.txt | 1.02 KB | larowlan |
| #5 | 3053832-refactor-module-list-form-2.patch | 13.74 KB | larowlan |
Issue fork drupal-3053832
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
larowlanComment #3
lendudeThis seems a little magical, wouldn't it be clearer if it just had a $hidden setting?
Is the existing test coverage enough to not add any here? I'm assuming that we have plenty of coverage for the module page, but might be nice to check and confirm that we do.
Since this is an important page that tends to be fairly heavy to load, do we need a quick profiling run for this to make sure we are not regressing here (nothing in the code makes me think we might, but who knows)?
Comment #4
larowlan#3
Fixed
Checked, we have tests in
\Drupal\Tests\system\Functional\Module\DependencyTestProfiling coming
Comment #5
larowlanComment #6
larowlanNegligible difference when profiling, both HEAD and with this patch take 18s to load on my local (which has all the contrib modules I work on in it)
Comment #7
kim.pepperI think we need a bit more info in the the issue summary. Why is this needed for #3005229: Provide optional support for using composer.json for dependency metadata? Can you expand on the changes a bit more? What are we doing to make a BC layer easier?
Comment #8
larowlanAdded
to issue summary
Comment #9
kim.pepperI like the introduction of the value object, and the static methods make it's usage intuitive. Although we could add a unit test, it seems too trivial to me.
Comment #10
lendude@larowlan thanks for doing the profiling/test check steps. RTBC++
Comment #12
kim.pepperRandom test fails.
Comment #13
alexpottSo much complexity.
The whole hidden thing is really really not nice. What's a hidden dependency?!?! The answer is one that doesn't count. And that's where I think this solution might do with a little finesse because it got very confusing trying to work out what
The
$instance->satisfiedmeant in this case.It really means ignore so rather than creating a DependencyEvaluationResult how about returning FALSE. Meaning we've ignored the dependency. That way this whole hidden thing has no meaning outside this form - which it doesn't atm but this patch makes it suddenly have.
Also I always find it remarkable that some much logic about where something can be installed or uninstalled is buried in this form. Plus all the uninstall logic side of things is moot because that's not handled here any more.
Comment #14
larowlanYep, this is a step towards untangling it. It is indeed frightening.
Made that change for hidden
Comment #15
kim.pepperFeedback from #13 has been addressed to back to RTBC
Comment #16
alexpottSo the only thing I'm pondering now is the location of this class. It's not a really a generic class at all. Like Drush or Console couldn't use it to improve or re-use their dependency messages whilst enabling a module. The logic they'd need is still all in the form. For me this class really boils down to a nice way to return a multiple values (the message and whether or not the dependency is satisfied) from the new buildDependencyEvaluationResult method. So for me this thing probably ought to be in the same location or very near that form.
I think the arguments should be the other ways around. We're evaluating the dependency so it makes sense that it is the first argument.
Comment #17
mxr576I am adding #3060241 as a related issue because both the
ModuleListFormand theModuleInstallershould use the same component to resolve and validate dependencies, when a dependency validation fails they should both handle it properly.Comment #26
nicxvan commented