function _drush_pm_filter_releases

4.x _drush_pm_filter_releases($releases, $all = FALSE, $dev = FALSE, $show_all_until_installed = TRUE)

Filter a list of releases.


$releases: Array of release information

$all: Show all releases. If FALSE, shows only the first release that is Recommended or Supported or Security or Installed.

$dev: Show only development release.

$show_all_until_installed: If TRUE, then all releases will be shown until the INSTALLED release is found, at which point the algorithm will stop.

2 calls to _drush_pm_filter_releases()
drush_pm_releases in commands/pm/
Command callback. Show available releases for given project(s).
_drush_pm_download_releases_choice in commands/pm/
Return an array of available releases for given project(s).


commands/pm/, line 1316
The drush Project Manager


function _drush_pm_filter_releases($releases, $all = FALSE, $dev = FALSE, $show_all_until_installed = TRUE) {
  // Start off by sorting releases by release date.
  uasort($releases, '_drush_pm_compare_date');
  // Find version_major for the installed release
  $installed_version_major = FALSE;
  foreach ($releases as $version => $release_info) {
    if (in_array("Installed", $release_info['release_status'])) {
      $installed_version_major = $release_info['version_major'];
  // Now iterate through and filter out the releases we're
  // interested in.
  $options = array();
  $limits_list = array();
  foreach ($releases as $version => $release_info) {
    if (!$dev || ((array_key_exists('version_extra', $release_info)) && ($release_info['version_extra'] == 'dev'))) {
      $saw_unique_status = FALSE;
      foreach ($release_info['release_status'] as $one_status) {
        // We will show the first release of a given kind;
        // after we show the first security release, we show
        // no other.  We do this on a per-major-version basis,
        // though, so if a project has three major versions, then
        // we will show the first security release from each.
        // This rule is overridden by $all and $show_all_until_installed.
        $test_key = $release_info['version_major'] . $one_status;
        if (!array_key_exists($test_key, $limits_list)) {
          $limits_list[$test_key] = TRUE;
          $saw_unique_status = TRUE;
          // Once we see the "Installed" release we will stop
          // showing all releases
          if ($one_status == "Installed") {
            $show_all_until_installed = FALSE;
            $installed_release_date = $release_info['date'];
      if ($all || ($show_all_until_installed && ($installed_version_major == $release_info['version_major'])) || $saw_unique_status) {
        $options[$release_info['version']] = $release_info;
  // If "show all until installed" is still true, that means that
  // we never encountered the installed release anywhere in releases,
  // and therefore we did not filter out any releases at all.  If this
  // is the case, then call ourselves again, this time with
  // $show_all_until_installed set to FALSE from the beginning.
  // The other situation we might encounter is when we do not encounter
  // the installed release, and $options is still empty.  This means
  // that there were no supported or recommented or security or development
  // releases found.  If this is the case, then we will force ALL to TRUE
  // and show everything on the second iteration.
  if (($all === FALSE) && ($show_all_until_installed === TRUE)) {
    $options = _drush_pm_filter_releases($releases, empty($options), $dev, FALSE);
  return $options;