function _drush_backend_batch_process

8.0.x batch_6.inc _drush_backend_batch_process($command = 'batch-process', $args, $options)
8.0.x batch.inc _drush_backend_batch_process($command = 'batch-process', $args, $options)
6.x batch_6.inc _drush_backend_batch_process($command = 'batch-process', $args, $options)
6.x batch.inc _drush_backend_batch_process($command = 'batch-process', $args, $options)
7.x batch_6.inc _drush_backend_batch_process($command = 'batch-process', $args, $options)
7.x batch.inc _drush_backend_batch_process($command = 'batch-process', $args, $options)
3.x batch_6.inc _drush_backend_batch_process($command = 'batch-process')
3.x batch_7.inc _drush_backend_batch_process($command = 'batch-process')
4.x batch_6.inc _drush_backend_batch_process($command = 'batch-process')
4.x batch.inc _drush_backend_batch_process($command = 'batch-process')
5.x batch_6.inc _drush_backend_batch_process($command = 'batch-process', $args, $options)
5.x batch.inc _drush_backend_batch_process($command = 'batch-process', $args, $options)
master batch.inc _drush_backend_batch_process($command = 'batch-process', $args, $options)

Main loop for the Drush batch API.

Saves a record of the batch into the database, and progressively call $command to process the operations.

Parameters

command: The command to call to process the batch.

1 call to _drush_backend_batch_process()
drush_backend_batch_process in includes/batch.inc
Process a Drupal batch by spawning multiple Drush processes.

File

commands/core/drupal/batch_6.inc, line 17
Drupal 6 engine for the Batch API

Code

function _drush_backend_batch_process($command = 'batch-process') {
  global $user;
  $batch = &batch_get();

  if (isset($batch)) {
    $process_info = array(
      'current_set' => 0,
    );
    $batch += $process_info;

    // Initiate db storage in order to get a batch id. We have to provide
    // at least an empty string for the (not null) 'token' column.
    db_query("INSERT INTO {batch} (token, timestamp) VALUES ('', %d)", time());
    $batch['id'] = db_last_insert_id('batch', 'bid');

    // Actually store the batch data and the token generated form the batch id.
    db_query("UPDATE {batch} SET token = '%s', batch = '%s' WHERE bid = %d", drupal_get_token($batch['id']), serialize($batch), $batch['id']);

    $finished = FALSE;

    while (!$finished) {
      if ($user->uid) {
        $data = drush_backend_invoke($command, array($batch['id'], '-u', $user->uid));
      }
      else {
        $data = drush_backend_invoke($command, array($batch['id']));
      }

      $finished = drush_get_error() || !$data || (isset($data['context']['drush_batch_process_finished']) && $data['context']['drush_batch_process_finished'] == TRUE);
    }
  }
}