Background

Occasionally, project maintainers will forget to select the recommended version when they release new versions to drupal.org. Currently cck, captcha, features_extra, and media_vimeo are among those with no recommended version although they all have supported versions. If drush pm-download encounters a project without a recommended version, it will prompt the user to select from a list of recent versions unless the --select option is set to 'never'. If the assume yes option is set, pm-download will display the user prompt, but then continue on to download the most recent non-dev version (unless the --dev option is also specified).

drush make, by default sets the --select option to 'never'. When it encounters a project where the version is not specified in the makefile and the recommended version is not set by the maintainer, it will continue on without downloading the project or issuing a warning. The result is a broken site with unresolved dependencies. Example, the OpenChurch installation profile. The simplest fix is to change the default select option to 'auto' where drush make calls release_info_fetch. This changes the behavior of 'drush make' to be more like 'drush pm-download'.
It's not clear to me if the purpose of the --select=never option was to never prompt the user, or to never download the project. Currently, it does both which might be a bug if the intent was only to suppress the user prompt.

I'll prepare a patch when I have time tomorrow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonhattan’s picture

Component: Core Commands » Make

It's not clear to me if the purpose of the --select=never option was to never prompt the user, or to never download the project.

Never prompt. See #1371220: release_info_fetch() $select should be more flexible.

If make fails silently this is a bug.

dude4linux’s picture

Then we must have a bug. Here is a repeatable test.

# cat test.make
core = 7.x
api = 2

; Modules
; Latest stable captcha module
projects[] = captcha

Results from drush make. Note: the duplicate download is another bug - see 1417020#14

# drush make -y --no-core test.make /tmp/testing
There is no recommended release for project captcha.
captcha- downloaded.                                                                                                                                                                           [ok]
captcha- downloaded.                                                                                                                                                                           [ok]

# ls -l /tmp/testing/sites/all/modules/
total 0

drush environment

# git status
# On branch master
nothing to commit (working directory clean)

# git show
commit eac67df05b9f551e27941c7efb411d88f354056f
Author: Mark Sonnabaum <mark@sonnabaum.com>
Date:   Sun Feb 26 21:42:06 2012 -0600

# drush status
 PHP configuration     :  /etc/php5/cli/php.ini                                                                                              
 Drush version         :  5.0-dev                                                                                                            
 Drush configuration   :                                                                                                                     
 Drush alias files     :  /etc/drush/publisher.alias.drushrc.php /etc/drush/developer.alias.drushrc.php /etc/drush/drupal7.alias.drushrc.php
dude4linux’s picture

Sorry, I forgot to include

# drush rl captcha
------- RELEASES FOR 'CAPTCHA' PROJECT -------
 Release         Date         Status      
 7.x-1.x-dev     2012-Jan-02  Development 
 7.x-1.0-beta2   2012-Jan-02  Supported   
moshe weitzman’s picture

Status: Active » Fixed

I think the pm code is working as designed so I changed this to 'auto' and committed. See 63170a4f95cf653e687454d8978de3ca4fd97359

dude4linux’s picture

Status: Fixed » Needs work

@moshe - Thanks for looking into this. When I opened this ticket, I thought that setting the 'auto' select mode would be sufficient, however, additional testing showed there are error cases that aren't handled. Currently there are four modules I'm aware of that don't have a recommended version selected, cck, captcha, features_extra, and media_vimeo.

# drush rl cck captcha features_extra media_vimeo
------- RELEASES FOR 'CCK' PROJECT -------
 Release         Date         Status                 
 7.x-2.x-dev     2011-Aug-23  Supported, Development 

------- RELEASES FOR 'CAPTCHA' PROJECT -------
 Release         Date         Status      
 7.x-1.x-dev     2012-Jan-02  Development 
 7.x-1.0-beta2   2012-Jan-02  Supported   

------- RELEASES FOR 'FEATURES_EXTRA' PROJECT -------
 Release         Date         Status                 
 7.x-1.x-dev     2011-Jun-19  Supported, Development 

------- RELEASES FOR 'MEDIA_VIMEO' PROJECT -------
 Release         Date         Status      
 7.x-1.x-dev     2011-Dec-08  Development 
 7.x-1.0-beta4   2011-Dec-07  Supported   

My testing showed that setting select to 'auto' works for two of the above cases, cck and features_extra. The catch is that when more that one option is presented to the user, the assume_yes option defaults to cancel rather than continue so both captcha and media_vimeo fail to install. I've been working on testing an alternative patch which modifies updatexml_parse_release to return the latest supported release if no recommended release is found. It works for all four of the test cases, but I've been hesitant to post it because it also impacts the behavior of pm-download.

Add the following code to function updatexml_parse_release($request, $xml, $restrict_to = '') in commands/pm/release_info/updatexml.inc after "recommended" release and before "development" release.

  // If that did not work, we will get the first published release for the
  // supported majors version.
  if (empty($releases)) {
    if ($supported_major = $xml->xpath("/project/supported_majors")) {
      $xpath_releases = "/project/releases/release[status='published'][version_major=" . (string)$supported_major[0] . "]";
      $releases = @$xml->xpath($xpath_releases);
    }
  }
  // If there are supported releases (no 'version_extra' elements), then use
  // only supported releases.  
  // supported release defaults to the latest published release with the
  // right supported major version number.
  $supported_releases = array();
  if (!empty($releases)) {
    foreach ($releases as $one_release) {
      if (!array_key_exists('version_extra', $one_release)) {
        $supported_releases[] = $one_release;
      }
    }
  }
  if (!empty($supported_releases)) {
    $releases = $supported_releases;
  }
  $release_type = 'supported';
dude4linux’s picture

Here is a patch to make the change described above. Working on testing to make sure it causes no harm.

dude4linux’s picture

Results of unit testing:

There was 1 failure:

1) makeMakefileCase::testInfoFileWritingGit
Failed asserting that file "/tmp/drush-sandbox/home/.drush/cache/git/cck_signup-9408f8ae55142a8dafc9e7969c62a6f6" exists.

/opt/drush/tests/makeTest.php:204

FAILURES!
Tests: 77, Assertions: 531, Failures: 1, Skipped: 1.

I can't see that this is related to my patch since it occurs with and without the patch installed.

A couple of thoughts:

  1. What should happen if neither recommended nor supported is set?
  2. How to issue a warning when no file has been downloaded?
moshe weitzman’s picture

Patch is 0 bytes.

dude4linux’s picture

Opps. Sorry, my first attempt to use format-patch. I've got to learn to check everything twice :)
This should work better.

moshe weitzman’s picture

Component: Make » PM (dl, en, up ...)
Assigned: Unassigned » jonhattan
jonhattan’s picture

Title: Change drush make select default to 'auto' same as pm-download » Fallback to a supported release if no recommended is found
Status: Needs work » Fixed

Committed a refactor of the resulting code after applying #9.

Also reverted select => auto. Interactivity is bad for makefiles.

Status: Fixed » Closed (fixed)

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