Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
joachim CreditAttribution: joachim commentedHaving 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.
Comment #2
threexk CreditAttribution: threexk commentedsubscribe. 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.
Comment #3
BerdirCan you still reproduce this with latest HEAD? There were quite a few changes how dependencies are handled when installing modules.
Comment #4
greg.harveyI guess that falls to me - I'll need to port the code in that blog post to Drupal 7 and report back.
Comment #5
David_Rothstein CreditAttribution: David_Rothstein commentedIn 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).
Comment #6
greg.harveyThanks for the update. Unassigning myself... =)
Comment #7
valk CreditAttribution: valk commentedI 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.
Comment #8
David_Rothstein CreditAttribution: David_Rothstein commentedI think the remaining issues here were fixed with #833192: Installer might install modules in wrong order - please feel free to reopen if not.
Comment #9
greg.harveyYay! That rocks! =)
Comment #10
threexk CreditAttribution: threexk commentedThis issue originally for D6. Hoping for a patch backport in http://drupal.org/node/833192.