A standard practice of mine is to use hook_update_N() to trigger installation of new modules, e.g.:

function mymodule_update_7100() {
  $modules = array('new_module', 'another_module');
  module_enable($modules);
}

Recently, though, probably since around 7.19, this hasn't been working - the modules aren't enabled and they must be manually enabled instead. For comparison sake, using Drush to enable the modules does still work.

I have not yet tried replicating this on a bare core installation, to verify it isn't something else causing the problem, but I will.

Comments

berdir’s picture

matason’s picture

I've run into this issue today, @DamienMcKenna did you discover a workaround?

czigor’s picture

Version: 7.21 » 7.37
Issue summary: View changes

Same issue with 7.37.

czigor’s picture

False alarm, I cannot see this in 7.37.

perennial.sky’s picture

I didn't replicate this issue in 7.37 version

dshumaker’s picture

I'm seeing this with Drupal 7.41......

---edit---
ha... actually after checking the parameters, my problem was that I was passing a string instead of an array to module_enable. false alarm. For all the googlers that land here - make sure you are passing an array and not just a string to module_enable. that fixed it for me. :)

David_Rothstein’s picture

Version: 7.37 » 7.x-dev
Status: Active » Postponed (maintainer needs more info)

I've definitely used this technique many times and never run into a problem with it either. Seems like we need steps to reproduce here?

cobadger’s picture

I experienced this problem just now - it turned out that one of the modules in my array to be enabled had an unmet dependency. Once I 'drush dl'-ed that module, the module_enable() statement in my db update worked as intended.

Status: Postponed (maintainer needs more info) » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.