1 update.inc | update_upgrade_modules_to_enable() |
Finds out which modules need to be enabled.
Return value
array: An array keyed by the machine names of module names needed to be enabled, whose values are arrays of the modules that depend on them.
File
- core/
includes/ update.inc, line 348 - Backdrop site update API.
Code
function update_upgrade_modules_to_enable() {
// Get list of enabled modules.
$result = db_query("SELECT name FROM {system} WHERE type = :type AND status = :status", array(':type' => 'module', ':status' => 1));
// Get list of modules to be enabled.
$enabled_modules = array_keys($result->fetchAllAssoc('name'));
// Do not include any core module required by the Standard or Minimal
// installations. Any needed modules from those will be taken care of later.
$enabled_modules = array_diff($enabled_modules, array('standard', 'minimal'));
// Get information about all modules available.
$files = system_rebuild_module_data();
$modules_to_enable = array();
foreach ($enabled_modules as $enabled_module) {
if (!empty($files[$enabled_module]->requires)) {
$required_modules = array_keys($files[$enabled_module]->requires);
// Add required modules that are not enabled.
$modules_not_enabled = array_diff($required_modules, $enabled_modules);
foreach ($modules_not_enabled as $module_not_enabled) {
$modules_to_enable[$module_not_enabled][] = $files[$enabled_module]->info['name'];
}
}
}
return $modules_to_enable;
}