Problem/Motivation
The API for enabling modules fails silently if one of the modules is not present in the filesystem.
Proposed resolution
Throw an exception when this is the case.
Original bug report from duplicate issue
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.
Original bug report
Drupal 7: https://api.drupal.org/api/drupal/includes%21module.inc/function/module_...
Drupal 8: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...
if (!isset($module_data[$module])) {
// This module is not found in the filesystem, abort.
return FALSE;
}
The above snippet should include a watchdog call. Otherwise it's very difficult to find out why the module_enable() function is failing.
In Drupal 7, when enabling multiple modules, all modules up to the one that is missing will be installed, and the ones after will not be installed. This can cause instability issues.
In Drupal 8, the ModuleHandler::install() function is different in that it first checks to see if the modules all exist before installing any of them. So it's implementation is better, but it still doesn't report to the watchdog which module is missing.