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.

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 39
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'))) {
    drush_log(dt("Error: select strategy must be one of: auto, never, always", array(), 'error'));
    return FALSE;
  }

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

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

  if ($select != 'always') {
    // Try to identify the most appropriate release.
    $release = updatexml_parse_release($request, $xml, $restrict_to);
    if ($release) {
      return $release;
    }
    else {
      if ($select == 'never') {
        return FALSE;
      }
    }
  }

  $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 $project_info['releases'][$choice];
  }

  return FALSE;
}