Let's say you enable three modules in module_enable().
If one of them isn't in the file system, this is what happens:
if (!isset($module_data[$module])) {
// This module is not found in the filesystem, abort.
return FALSE;
}
No error gets thrown at all, and the rest of the modules don't get enabled either.
In my case this happened when a new module wasn't checked in to git, then a subsequent update called a function in it - the first error you get is the fatal error undefined function.
It probably makes sense to do a complete abort to avoid sites getting in a completely unrecoverable state, but could probably throw an expection instead of the return FALSE there.
This is less of an issue when only enabling one module - it's pretty obvious if it doesn't get enabled when it's not in the filesystem, but when it's a different module that happens to be enabled by the same function call but which otherwise would have been enabled without complaint it's a bit odd.
Comments
Comment #1
joachim commentedThis can cause real headaches when writing and running tests.
The modules that your test case requires can simply fail to enable, and then the whole of the rest of the test fails, for completely mysterious reasons!
So throwing an exception here would definitely be a big DX help.
Comment #2
joachim commentedUpdated title to reflect removal of module_enable() on D8.
Comment #3
ttkaminski commentedDuplicate of #1719648: ModuleInstaller::install() should provide more information than simply returning FALSE when a module isn't in the file system