protected function StatusInfoDrupal7::getAvailableReleases

8.0.x StatusInfoDrupal7.php protected StatusInfoDrupal7::getAvailableReleases()
7.x StatusInfoDrupal7.php protected StatusInfoDrupal7::getAvailableReleases()
master StatusInfoDrupal7.php protected StatusInfoDrupal7::getAvailableReleases()

Obtains release info for all installed projects via update.module.

Overrides StatusInfoDrupal8::getAvailableReleases

See also

update_get_available().

update_manual_status().

1 method overrides StatusInfoDrupal7::getAvailableReleases()
StatusInfoDrupal6::getAvailableReleases in lib/Drush/UpdateService/StatusInfoDrupal6.php
Obtains release info for all installed projects via update.module.

File

lib/Drush/UpdateService/StatusInfoDrupal7.php, line 60
Implementation of 'drupal' update_status engine for Drupal 7.

Namespace

Drush\UpdateService

Class

StatusInfoDrupal7

Code

protected function getAvailableReleases() {
  // Force to invalidate some caches that are only cleared
  // when visiting update status report page. This allow to detect changes in
  // .info files.
  _update_cache_clear('update_project_data');
  _update_cache_clear('update_project_projects');

  // From update_get_available(): Iterate all projects and create a fetch task
  // for those we have no information or is obsolete.
  $available = _update_get_cached_available_releases();

  module_load_include('inc', 'update', 'update.compare');
  $update_projects = update_get_projects();

  foreach ($update_projects as $key => $project) {
    if (empty($available[$key])) {
      update_create_fetch_task($project);
      continue;
    }
    if ($project['info']['_info_file_ctime'] > $available[$key]['last_fetch']) {
      $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
    }
    if (empty($available[$key]['releases'])) {
      $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
    }
    if (!empty($available[$key]['fetch_status']) && $available[$key]['fetch_status'] == UPDATE_FETCH_PENDING) {
      update_create_fetch_task($project);
    }
  }

  // Set a batch to process all pending tasks.
  $batch = array(
    'operations' => array(
      array('update_fetch_data_batch', array()),
    ),
    'finished' => 'update_fetch_data_finished',
    'file' => drupal_get_path('module', 'update') . '/update.fetch.inc',
  );
  batch_set($batch);
  drush_backend_batch_process();

  // Clear any error set by a failed update fetch task. This avoid rollbacks.
  drush_clear_error();

  // Calculate update status data.
  $available = _update_get_cached_available_releases();
  return $available;
}