_batch_finished
- 6 – 7
_batch_finished()
End the batch processing:
Call the 'finished' callbacks to allow custom handling of results,
and resolve page redirection.
- _batch_page in drupal/includes/batch.inc
- State-based dispatcher for the batch processing page.
- _batch_process in drupal/includes/batch.inc
- Advance batch processing for 1 second (or process the whole batch if it
was not set for progressive execution - e.g forms submitted by drupal_execute).
Code
drupal/includes/batch.inc, line 290
<?php
function _batch_finished() {
$batch =& batch_get();
foreach ($batch['sets'] as $key => $batch_set) {
if (isset($batch_set['finished'])) {
if (isset($batch_set['file']) && is_file($batch_set['file'])) {
include_once($batch_set['file']);
}
if (function_exists($batch_set['finished'])) {
$batch_set['finished']($batch_set['success'], $batch_set['results'], $batch_set['operations']);
}
}
}
if ($batch['progressive']) {
db_query("DELETE FROM {batch} WHERE bid = %d", $batch['id']);
}
$_batch = $batch;
$batch = NULL;
if ($_batch['progressive']) {
if (isset($_batch['destination'])) {
$_REQUEST['destination'] = $_batch['destination'];
}
if (isset($_batch['form_state']['redirect'])) {
$redirect = $_batch['form_state']['redirect'];
}
elseif (isset($_batch['redirect'])) {
$redirect = $_batch['redirect'];
}
else {
$redirect = $_batch['source_page'];
}
$form = isset($batch['form']) ? $batch['form'] : array();
if (empty($_batch['form_state']['rebuild']) && empty($_batch['form_state']['storage'])) {
drupal_redirect_form($form, $redirect);
}
$_SESSION['batch_form_state'] = $_batch['form_state'];
drupal_goto($_batch['source_page']);
}
}
?>