function release_info_fetch

6.x updatexml.inc release_info_fetch(&$request, $restrict_to = '', $select = 'never', $all = FALSE)
5.x updatexml.inc release_info_fetch(&$request, $restrict_to = '', $select = 'never', $all = FALSE)

Obtain the most appropiate release for the requested project.

Parameters

Array &$request: A project request as returned by pm_parse_project_version(). The array will be expanded with the project type.

String $restrict_to: One of: 'dev': Forces choosing a -dev release. 'version': Forces choosing a point release. '': No restriction. Default is ''.

String $select: Strategy for selecting a release, should be one of:

  • auto: Try to select the latest release, if none found allow the user to choose.
  • always: Force the user to choose a release.
  • never: Try to select the latest release, if none found then fail.
  • ignore: Ignore and return NULL.

If no supported release is found, allow to ask the user to choose one.

Boolean $all: In case $select = TRUE this indicates that all available releases will be offered the user to choose.

Return value

The selected release xml object.

2 calls to release_info_fetch()
drush_pm_download in commands/pm/download.pm.inc
Command callback. Download Drupal core or any project.
make_projects in commands/make/make.drush.inc
Process all projects specified in the make file.

File

commands/pm/release_info/updatexml.inc, line 41
Drush release info engine for update.drupal.org and compatible services.

Code

function release_info_fetch(&$request, $restrict_to = '', $select = 'never', $all = FALSE) {
  if (!in_array($select, array('auto', 'never', 'always', 'ignore'))) {
    return drush_set_error('DRUSH_PM_UNKNOWN_SELECT_STRATEGY', dt("Error: select strategy must be one of: auto, never, always, ignore", array()));
  }

  $xml = updatexml_get_release_history_xml($request);
  if (!$xml) {
    return FALSE;
  }

  $request['project_type'] = updatexml_determine_project_type($xml);

  if ($select != 'always') {
    if ($restrict_to == 'dev') {
      $release = updatexml_dev_release($request, $xml);
      if ($release === FALSE) {
        return drush_set_error('DRUSN_PM_NO_DEV_RELEASE', dt('There is no development release for project !project.', array('!project' => $request['name'])));
      }
    }
    if (empty($release)) {
      $release = updatexml_specific_release_version($request, $xml);
      if ($release === FALSE) {
        return drush_set_error('DRUSH_PM_COULD_NOT_FIND_VERSION', dt("Could not locate !project version !version.", array('!project' => $request['name'], '!version' => $request['version'])));
      }
    }
    // If there was no specific release requested, try to identify the most appropriate release.
    if (empty($release)) {
      $release = updatexml_most_appropriate_release($request, $xml);
    }
    if ($release) {
      return $release;
    }
    else {
      $message = dt('There are no stable releases for project !project.', array('!project' => $request['name']));
      if ($select == 'never') {
        return drush_set_error('DRUSH_PM_NO_STABLE_RELEASE', $message);
      }
      drush_log($message, 'warning');
      if ($select == 'ignore') {
        return;
      }
    }
  }

  $project_info = updatexml_get_releases_from_xml($xml, $request['name']);
  $releases = release_info_filter_releases($project_info['releases'], $all, $restrict_to);
  $options = array();
  foreach ($releases as $version => $release) {
    $options[$version] = array(
      $version,
      '-',
      gmdate('Y-M-d', $release['date']),
      '-',
      implode(', ', $release['release_status']),
    );
  }
  $choice = drush_choice($options, dt('Choose one of the available releases for !project:', array('!project' => $request['name'])));
  if (!$choice) {
    return drush_user_abort();
  }

  return $project_info['releases'][$choice];
}