示例#1
1
 /**
  * Starts the batch process depending on where it was requested from.
  */
 public function start()
 {
     switch ($this->batchInfo['from']) {
         case 'form':
             batch_set($this->batch);
             break;
         case 'drush':
             batch_set($this->batch);
             $this->batch =& batch_get();
             $this->batch['progressive'] = FALSE;
             drush_log(t(self::BATCH_INIT_MESSAGE), 'status');
             drush_backend_batch_process();
             break;
         case 'backend':
             batch_set($this->batch);
             $this->batch =& batch_get();
             $this->batch['progressive'] = FALSE;
             batch_process();
             //todo: Does not take advantage of batch API and eventually runs out of memory on very large sites.
             break;
         case 'nobatch':
             $context = [];
             foreach ($this->batch['operations'] as $i => $operation) {
                 $operation[1][] =& $context;
                 call_user_func_array($operation[0], $operation[1]);
             }
             self::finishGeneration(TRUE, $context['results'], []);
             break;
     }
 }
示例#2
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();
 }
示例#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;
 }