batch_process

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 batch_process($redirect = NULL, $url = NULL)

Process the batch.

Unless the batch has been marked with 'progressive' = FALSE, the function issues a drupal_goto and thus ends page execution.

This function is generally not needed in form submit handlers; Form API takes care of batches that were set during form submission.

Übergabeparameter

$redirect (optional) Path to redirect to when the batch has finished processing.

$url (optional - should only be used for separate scripts like update.php) URL of the batch processing page.

Verwandte Themen

▾ 6 functions call batch_process()

drupal_process_form in includes/form.inc
This function is the heart of form API. The form gets built, validated and in appropriate cases, submitted.
form_test_drupal_form_submit_batch_api in modules/simpletest/tests/form_test.module
Page callback for the batch/drupal_form_submit interaction test.
install_tasks in ./install.php
Tasks performed after the database is initialized.
simpletest_run_tests in modules/simpletest/simpletest.module
Actually runs tests.
update_batch in ./update.php
user_cancel_confirm in modules/user/user.pages.inc
Menu callback; Cancel a user account via e-mail confirmation link.

Code

includes/form.inc, line 2908

<?php
function batch_process($redirect = NULL, $url = NULL) {
  $batch = & batch_get();

  if (isset($batch)) {
    // Add process information
    $url = isset($url) ? $url : 'batch';
    $process_info = array(
      'current_set' => 0,
      'progressive' => TRUE,
      'url' => isset($url) ? $url : 'batch',
      'source_page' => $_GET['q'],
      'redirect' => $redirect,
    );
    $batch += $process_info;

    if ($batch['progressive']) {
      // Clear the way for the drupal_goto redirection to the batch processing
      // page, by saving and unsetting the 'destination' if any, on both places
      // drupal_goto looks for it.
      if (isset($_REQUEST['destination'])) {
        $batch['destination'] = $_REQUEST['destination'];
        unset($_REQUEST['destination']);
      }

      // 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.
      $batch['id'] = db_insert('batch')
        ->fields(array(
          'token' => '',
          'timestamp' => REQUEST_TIME,
        ))
        ->execute();

      // Now that we have a batch id, we can generate the redirection link in
      // the generic error message.
      $t = get_t();
      $batch['error_message'] = $t('Please continue to <a href="@error_url">the error page</a>', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished')))));

      // Actually store the batch data and the token generated form the batch id.
      db_update('batch')
        ->condition('bid', $batch['id'])
        ->fields(array(
          'token' => drupal_get_token($batch['id']),
          'batch' => serialize($batch),
        ))
        ->execute();

      drupal_goto($batch['url'], 'op=start&id=' . $batch['id']);
    }
    else {
      // Non-progressive execution: bypass the whole progressbar workflow
      // and execute the batch in one pass.
      require_once DRUPAL_ROOT . '/includes/batch.inc';
      _batch_process();
    }
  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen