Hi,
in a code-driven development workflow, we often get into a situation where a new version of a module introduces new dependencies, that have not been there in a previous version. While "drush en" does check those dependencies, this does not help if the module is already enabled. The usual drush commands you run after git pull, namely "drush updb" and "drush cc all", are also not able to deal with dependencies (and that is not their job).

I propose to introduce two new commands:

drush pm-enable-dependencies
Download and enable dependencies of all enabled modules (with confirm dialog).

drush pm-find-obsolete [module 1] [module 2] [module 3]
Find all modules that could be safely disabled without disabling any of the modules specified as arguments.

The two commands are already implemented in my sandbox, see
http://drupal.org/sandbox/donquixote/1436342
(or might be http://drupal.org/project/drux some day, if I don't find a better name)

drush dep
(drux-enable-dependencies)
Download and enable dependencies of all enabled modules.

drush obs [module 1] [module 2] [module 3]
(drux-find-obsolete)
Find all modules that could be safely disabled without disabling any of the modules specified as arguments.

Use case: The PULL situation

You pull code (modules and features) that a fellow developer has worked on. These modules could contain new dependencies. You run "drush updb" and "drush cc all", but the dependencies are still not enabled.

Solution:
Now in addition you run "drush dep", and everything is fine.

Use case: The PUSH situation

You worked on some modules (incl features), and want to push them upstream. Your fellow developers need to know which other modules they need to enable, so you add those as dependencies. But, how can you be sure you did not forget a dependency?

Solution:
You have one or more "seed" modules, with all the dependencies. You agree in your team that these should always be enabled.
You might also have a "personal seed module", which contains the dependencies you do not want to share with the team.

Whenever you enable a new module, and you want everyone in your team to also enable it, you add it as a dependency somewhere, so it becomes a direct or indirect dependency of the seed module(s).

You can then run "drush obs seed1 seed2 seed_personal" to identify all the modules you forgot to add as dependency. You should either disable these modules, or add them as dependencies somewhere.

Btw, my sandbox implementation could also be used for a refactored version of pm-enable ..

The code in there requires xautoload as a dependency. I wonder if that is possible to have a dependency in drush core, for specific commands? Otherwise, xautoload contains example code that allows to easily emulate it.

I think this stuff would be better off in drush core, as it seems like a vital component for code-driven development.

Comments

moshe weitzman’s picture

Status: Active » Postponed (maintainer needs more info)

I'd like to understand how and where in the code drupal core 6 and 7 handle this. my impression is that support is lacking for dependency changes. i don't know that drush should fix those.

The code in the sandbox looks unlike existing drush code at first glance and thus is unlikely to go in as is.

donquixote’s picture

I'd like to understand how and where in the code drupal core 6 and 7 handle this. my impression is that support is lacking for dependency changes. i don't know that drush should fix those.

I have the same impression. I would be bold and say: Drupal core does not support dependency changes.
Yet, they are a typical thing to happen in code-driven development. And doing that with hook_update_N() is plain ugly.

The consequence could be, that we also want a UI side of things, instead of just a drush command. This would not be possible in drush. So, one reason to publish as a separate module?

The code in the sandbox looks unlike existing drush code at first glance

I would never pretend it does.
This thing is still a module, not a mere drush extension. Reason number one is, I don't know how to get a module dependency into a drush extension. Probably just by "if module_exists('xautoload')".
The other difference is that this code is not one ugly big function, like drush_pm_enable(). In fact that's what I started with, copying and adapting drush_pm_enable(), but I found that unmanageable.

unlikely to go in as is.

This feature request is a proposal. If anyone asks me "why did you not try to get this into drush core", I can say "did that".
I could still consider putting it in drush extras. Or otherwise, let it live as a separate module.

Maybe this separate module can support dependency changes both on the commandline and in the UI. This would not be possible in drush alone.

maintainer needs more info

That's about all the info you can get :)

moshe weitzman’s picture

Status: Postponed (maintainer needs more info) » Needs work

In your command definition, you have a 'drupal dependencies' array, for defining stuff like xautoload.

IMO, the best place for this work is Drupal core. I'm a reluctant to put it into Drush core before then. If you want to rejigger the code to look like Drush code, then I'll evaluate the patch for Drush core.

donquixote’s picture

If you want to rejigger the code to look like Drush code, then I'll evaluate the patch for Drush core.

Are you more concerned about the implementation, or about the surrounding stuff, such as, having an info file and a module file?
Also, for the xautoload thing, I need to rethink, currently that only works for enabled modules. Maybe I need to include the files manually.

gagarine’s picture

Version: » All-versions-4.x-dev

This answer my question http://drupal.stackexchange.com/questions/77533/enable-new-modules-depen...

This is a important feature request for https://github.com/antistatique/capdrupal - capistrano recipies for working with drupal.(see bug https://github.com/antistatique/capdrupal/issues/10 ). I really hop it can be added in drush core.

greg.1.anderson’s picture

Version: All-versions-4.x-dev » 8.x-6.x-dev
Status: Needs work » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.