Esempio n. 1
0
 /**
  * Obtains release info for all installed projects via update.module.
  *
  * @see update_get_available().
  * @see \Drupal\update\Controller\UpdateController::updateStatusManually()
  */
 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();
 }
Esempio n. 2
0
 /**
  * Obtains release info for projects.
  */
 private function getAvailableReleases($projects)
 {
     drush_log(dt('Checking available update data ...'), LogLevel::OK);
     $release_info = drush_include_engine('release_info', 'updatexml');
     $available = array();
     foreach ($projects as $project_name => $project) {
         // Discard projects with unknown installation path.
         if ($project_name != 'drupal' && !isset($project['path'])) {
             continue;
         }
         drush_log(dt('Checking available update data for !project.', array('!project' => $project['label'])), LogLevel::OK);
         $request = pm_parse_request($project_name, NULL, $project_name);
         $project_release_info = $release_info->get($request);
         if ($project_release_info) {
             $available[$project_name] = $project_release_info;
         }
     }
     // Clear any error set by a failed project. This avoid rollbacks.
     drush_clear_error();
     return $available;
 }
Esempio n. 3
0
 /**
  * Obtains release info for all installed projects via update.module.
  *
  * @see update_get_available().
  * @see update_manual_status().
  */
 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;
 }