protected function StatusInfoDrupal8::getAvailableReleases

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

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

See also

update_get_available().

\Drupal\update\Controller\UpdateController::updateStatusManually()

1 call to StatusInfoDrupal8::getAvailableReleases()
StatusInfoDrupal8::getStatus in lib/Drush/UpdateService/StatusInfoDrupal8.php
Get update information for all installed projects.
1 method overrides StatusInfoDrupal8::getAvailableReleases()
StatusInfoDrupal7::getAvailableReleases in lib/Drush/UpdateService/StatusInfoDrupal7.php
Obtains release info for all installed projects via update.module.

File

lib/Drush/UpdateService/StatusInfoDrupal8.php, line 95
Implementation of 'drupal' update_status engine for Drupal 8.

Namespace

Drush\UpdateService

Class

StatusInfoDrupal8

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.yml files.
  \Drupal::keyValueExpirable('update')->deleteMultiple(array('update_project_projects', 'update_project_data'));

  // From update_get_available(): Iterate all projects and create a fetch task
  // for those we have no information or is obsolete.
  $available = \Drupal::keyValueExpirable('update_available_releases')->getAll();
  $update_projects = \Drupal::service('update.manager')->getProjects();
  foreach ($update_projects as $key => $project) {
    if (empty($available[$key])) {
      \Drupal::service('update.processor')->createFetchTask($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) {
      \Drupal::service('update.processor')->createFetchTask($project);
    }
  }

  // Set a batch to process all pending tasks.
  $batch = array(
    'operations' => array(
      array(array(\Drupal::service('update.manager'), 'fetchDataBatch'), 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();

  return \Drupal::keyValueExpirable('update_available_releases')->getAll();
}