If your module's hook_install calls functions in modules, even if they are marked as dependencies, installation can fail with a WSOD due to missing functions. You can get around this with a hook_requirements (see this post for details: http://www.drupaler.co.uk/blog/using-hookrequirements-drupal-6x/135) but it would be far better if Drupal installed the dependencies as a batch and then invoked install.php *again* to install the initially requested module. This would be far safer behaviour. =)

Comments

joachim’s picture

Category: feature » bug

Having to use hook_requirements() to check dependencies is a faff. It's also a violation of DRY. Once a dependency is set in the .info file, it should be possible to trust that Drupal enforces this and not need to check for the existence of it ever again (unless you have weird requirements like specific versions). I'd call this a bug.

threexk’s picture

subscribe. I am trying to create a CCK content type programmatically in my module at install, but this fails if several CCK modules are not installed even if they're listed as dependencies.

I agree with the bug categorization: the reasonable expectation is that a dependency will be available to a dependent module before any of its code runs. Thanks for the workaround, Greg.Harvey.

Berdir’s picture

Can you still reproduce this with latest HEAD? There were quite a few changes how dependencies are handled when installing modules.

greg.harvey’s picture

Assigned: Unassigned » greg.harvey
Status: Active » Postponed

I guess that falls to me - I'll need to port the code in that blog post to Drupal 7 and report back.

David_Rothstein’s picture

Status: Postponed » Active

In Drupal 7, this doesn't seem to be an issue when installing a module on an existing site. However, I can reproduce the problem when installing Drupal itself; I think the modules are installed in the order they are listed in the install profile's .info file, regardless of any dependencies. So things can break unless the profile author makes sure to list the modules in a special order.

I thought there was another issue for this somewhere, but can't find it at the moment (#731944: Module dependencies not considered during Installation Profile installation may be related).

greg.harvey’s picture

Assigned: greg.harvey » Unassigned

Thanks for the update. Unassigning myself... =)

valk’s picture

I had the same problem.
Looks like dependencies don't count in relation to modules install order.

My solution was to move the code to hook_enable().
I realize that this is not a solution, but hope this can help others.

David_Rothstein’s picture

Status: Active » Fixed

I think the remaining issues here were fixed with #833192: Installer might install modules in wrong order - please feel free to reopen if not.

greg.harvey’s picture

Yay! That rocks! =)

threexk’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Active

This issue originally for D6. Hoping for a patch backport in http://drupal.org/node/833192.

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.