The attached patch cleans up the code and messages when you choose to download a missing dependency.

For example - on a clean drupal site if you issue the following drush commands on a clean d7 site:

$ drush dl views_bulk_operations
$ drush en views_bulk_operations

Without the patch the following questions to resolve the dependency would happen:

Would you like to download the following projects to resolve unmet dependencies: views for views (y/n):
Would you like to download the following projects to resolve unmet dependencies: ctools for ctools (y/n):

With the patch:

Would you like to download the following projects to resolve unmet dependencies: views for views_bulk_operations (y/n):
Would you like to download the following projects to resolve unmet dependencies: ctools for views_bulk_operations (y/n):

it also resets the static system_rebuild_module_data to ensure you are always working with up-to-date information about which modules are available.

Comments

kotnik’s picture

Status: Active » Reviewed & tested by the community

Seems reasonable.

greg.1.anderson’s picture

Status: Reviewed & tested by the community » Needs work

That is a good improvement to the confirmation message -- although it would be even better, I think, if it could say "ctools for views". However, you made a change that will not work out in the long run. You cannot change the key of this line:

$resolved_projects[$project][] = $unmet;

The key must be $project so that pm-download is called but once per project needed to fulfill an unmet dependency. You changed the key as follows:

$resolved_projects[$unmet][] = $module;

This isn't good, because you threw away $project. In the current implementation, $project always == $unmet, but in the future it might not. For example:

Project views contains 3 modules: views_export, views_ui, views.

If the unmet dependency is views_export, then $project will be views, and $unmet will be views_export. Maybe it would work if you just put $project back as the key of $resolved_projects.

alexpott’s picture

StatusFileSize
new3.46 KB

Here's a better patch that addresses greg.1.anderson's concerns and (imo) improves the messages.

Another important part of the patch is refreshing the $extenstion_info array after the new modules are downloaded. This prevents the final test (enabling views_bulk_operations on a D7 sites) from asking the user to download views twice.

For the first test I've got a d6 site with spaces and panels_everywhere in sites/all/modules

Current drush-HEAD the cmd $ drush en spaces_og panels_everywhere would output:

Would you like to download the following projects to resolve unmet dependencies: ctools for ctools,page_manager;purl for purl;og for og_views,og_access,og;panels for panels (y/n):

With the attached patch the cmd $ drush en spaces_og panels_everywhere would output:

The following projects have unmet dependencies:
spaces_og requires ctools, purl, og
panels_everywhere requires ctools, panels
Would you like to download them? (y/n):

The example I gave for $ drush en views_bulk_operations on a D7 site in the initial issue now looks like this:

The following projects have unmet dependencies:
views_bulk_operations requires views
Would you like to download them? (y/n): y
Project views (7.x-3.0-alpha1) downloaded to /home/alex/public_html/drupal/sites/all/modules/views.
Project views contains 3 modules: views_export, views_ui, views.
The following projects have unmet dependencies:
views_bulk_operations requires ctools
Would you like to download them? (y/n): y
Project ctools (7.x-1.0-alpha2) downloaded to /home/alex/public_html/drupal/sites/all/modules/ctools.
greg.1.anderson’s picture

Status: Needs work » Needs review

Code looks good, output looks good; will test.

jonhattan’s picture

Status: Needs review » Fixed

reviewed and commited. thanks.

jonhattan’s picture

Version: » All-versions-4.x-dev
Assigned: Unassigned » msonnabaum
Status: Fixed » Patch (to be ported)

Not sure if it should be backported. It improves usability of site-upgrade

greg.1.anderson’s picture

Yes, I think it would be great if this went into drush-4.

msonnabaum’s picture

Status: Patch (to be ported) » Fixed

Backported.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.