Postponed until 8.1.x
Parent issue
#2024083: [META] Improve the extension system (modules, profiles, themes)
Problem/Motivation
Currently it is possible to install a module without installing a dependency. Installing a module without its dependencies is dangerous as it potentially leaves your site in a broken state where module B tries to invoke code or use objects from module A which either does not exist in the first place or lies there, inactivated, without it's code included and without it being registered with the classloader. The same is true for uninstalling modules without uninstalling dependent modules beforehand which is equally risky.
To me it looks like we added this feature for things like allowing the site installation batch process to cleanly install modules one by one without the risk of timeouts. Another place where we currently use it is the modules page submit handler where we handle dependencies, version miss-matches, etc. outside of ModuleHandler, basically duplicating half of what ModuleHandler already does anyways. This adds even more weight to the already hardly maintainable code around module installation, uninstallation, etc. and from a first glance it doesn't look like anyone touched that code in years. Other than that, it is only used in tests.
Proposed resolution
Let's remove it and refactor our site installation batch and the modules page submit handler to rely on ModuleHandler for building the dependency tree and installation order for modules.
Site installation
This can be solved by retrieving the module dependency tree as a properly sorted list through ModuleHandler and then incrementally installing them one by one.
Modules page
We still want to show a confirmation form if a module was selected for installation that has currently uninstalled dependencies (same with uninstallation). The actual installation and dependency management and sorting should happen in ModuleHandler though allowing us to remove about 50% of the code from the submit handler and moving some parts into the ModuleHandler (like version validation/miss-match detection or sorting based on dependencies which we currently lack interface methods for on ModuleHandler).
Remaining tasks
We should probably clean up and extend ModuleHandler beforehand so the patch for removing the '(un)install without dependencies/dependents" patch does not get any bigger than it has to.
User interface changes
None.
API changes
Removing $install_dependencies/$uninstall_dependents from ModuleHandler::install()/ModuleHandler::uninstall().
Related Issues
TBD
Comments
Comment #1
fubhy CreditAttribution: fubhy commentedThe fact that we support this just shows that the code where we use it is broken.
Just take the installer as an example. It uses this to make sure that, during the batch, we install our modules one at a time. If we had a proper, sorted graph we would not even need that as we could just retrieve that graph from the ModuleHandler and then iterate over it one by one. By that we would ensure that we never install a module for which we still need to install dependencies. Ensuring that would be the job of the graph. Problem solved.
Comment #1.0
fubhy CreditAttribution: fubhy commentedUpdated issue summary.
Comment #2
sunComment #3
filijonka CreditAttribution: filijonka commentedPostponing this to 8.1.x since META has been changed to that and also there are API chnages which isn't allowed during BETA phase per https://www.drupal.org/core/beta-changes
Comment #4
David_Rothstein CreditAttribution: David_Rothstein commentedChanging the API to remove this capability isn't likely on the table for Drupal 8 at this point, right?
But refactoring the code to do things differently (and/or providing alternate ways to do it) seems like it could get into 8.1.x. However, need to make sure not to kill performance... recalculating the dependency tree every time a new module is installed can be wasteful if you already know the dependency tree.
Comment #19
andypostno reason to postpone