function _drush_batch_finished

8.0.x batch_6.inc _drush_batch_finished()
8.0.x batch.inc _drush_batch_finished()
6.x batch_6.inc _drush_batch_finished()
6.x batch.inc _drush_batch_finished()
7.x batch_6.inc _drush_batch_finished()
7.x batch.inc _drush_batch_finished()
3.x batch_6.inc _drush_batch_finished()
3.x batch_7.inc _drush_batch_finished()
4.x batch_6.inc _drush_batch_finished()
4.x batch.inc _drush_batch_finished()
5.x batch_6.inc _drush_batch_finished()
5.x batch.inc _drush_batch_finished()
master batch.inc _drush_batch_finished()

End the batch processing: Call the 'finished' callbacks to allow custom handling of results, and resolve page redirection.

1 call to _drush_batch_finished()
_drush_batch_command in commands/core/drupal/batch.inc
Initialize the batch command and call the worker function.

File

commands/core/drupal/batch.inc, line 231
Drupal 7 engine for the Batch API

Code

function _drush_batch_finished() {
  $batch = &batch_get();

  // Execute the 'finished' callbacks for each batch set, if defined.
  foreach ($batch['sets'] as $batch_set) {
    if (isset($batch_set['finished'])) {
      // Check if the set requires an additional file for function definitions.
      if (isset($batch_set['file']) && is_file($batch_set['file'])) {
        include_once DRUPAL_ROOT . '/' . $batch_set['file'];
      }
      if (is_callable($batch_set['finished'])) {
        $queue = _batch_queue($batch_set);
        $operations = $queue->getAllItems();
        $elapsed = $batch_set['elapsed'] / 1000;
        $elapsed = drush_drupal_major_version() >= 8 ? \Drupal::service('date.formatter')->formatInterval($elapsed) : format_interval($elapsed);
        $batch_set['finished']($batch_set['success'], $batch_set['results'], $operations, $elapsed);
      }
    }
  }

  // Clean up the batch table and unset the static $batch variable.
  if (drush_drupal_major_version() >= 8) {
    /** @var \Drupal\Core\Batch\BatchStorage $batch_storage */
    $batch_storage = \Drupal::service('batch.storage');
    $batch_storage->delete($batch['id']);
  }
  else {
    db_delete('batch')->condition('bid', $batch['id'])->execute();
  }

  foreach ($batch['sets'] as $batch_set) {
    if ($queue = _batch_queue($batch_set)) {
      $queue->deleteQueue();
    }
  }
  $_batch = $batch;
  $batch = NULL;
  drush_set_option('drush_batch_process_finished', TRUE);
}