Index: includes/batch.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/batch.inc,v retrieving revision 1.37 diff -u -p -r1.37 batch.inc --- includes/batch.inc 26 Aug 2009 15:00:17 -0000 1.37 +++ includes/batch.inc 18 Sep 2009 14:58:29 -0000 @@ -450,7 +450,12 @@ function _batch_finished() { // multi-step form. We save the final $form_state value to be retrieved // by drupal_get_form(), and redirect to the originating page. $_SESSION['batch_form_state'] = $_batch['form_state']; - drupal_goto($_batch['source_page']); + if (empty($_batch['redirect_callback']) || $_batch['redirect_callback'] === 'drupal_goto') { + drupal_goto($_batch['source_page']); + } + elseif (function_exists($_batch['redirect_callback'])) { + call_user_func_array($_batch['redirect_callback'], array($_batch['id']), 'finish'); + } } } Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.373 diff -u -p -r1.373 form.inc --- includes/form.inc 18 Sep 2009 00:12:45 -0000 1.373 +++ includes/form.inc 18 Sep 2009 14:58:52 -0000 @@ -2902,8 +2902,13 @@ function batch_set($batch_definition) { * @param $url * (optional - should only be used for separate scripts like update.php) * URL of the batch processing page. + * @param $redirect_callback + * (optional) Specify a function to be called to redirect to the progressive + * processing page. By default drupal_goto() will be used to redirect to a + * page which will do the progressive page. Specifying another function will + * allow the progressive processing to be processed differently. */ -function batch_process($redirect = NULL, $url = NULL) { +function batch_process($redirect = NULL, $url = NULL, $redirect_callback = NULL) { $batch =& batch_get(); drupal_theme_initialize(); @@ -2918,6 +2923,7 @@ function batch_process($redirect = NULL, 'source_page' => $_GET['q'], 'redirect' => $redirect, 'theme' => $GLOBALS['theme_key'], + 'redirect_callback' => $redirect_callback, ); $batch += $process_info; @@ -2956,7 +2962,12 @@ function batch_process($redirect = NULL, // Set the batch number in the session to guarantee that it will stay alive. $_SESSION['batches'][$batch['id']] = TRUE; - drupal_goto($batch['url'], 'op=start&id=' . $batch['id']); + if (empty($redirect_callback) || $redirect_callback === 'drupal_goto') { + drupal_goto($batch['url'], 'op=start&id=' . $batch['id']); + } + elseif (function_exists($redirect_callback)) { + call_user_func_array($redirect_callback, array($batch['id']), 'start'); + } } else { // Non-progressive execution: bypass the whole progressbar workflow Index: includes/update.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/update.inc,v retrieving revision 1.8 diff -u -p -r1.8 update.inc --- includes/update.inc 18 Sep 2009 00:04:21 -0000 1.8 +++ includes/update.inc 18 Sep 2009 14:57:49 -0000 @@ -484,8 +484,11 @@ class DrupalUpdateException extends Exce * scripts like update.php). * @param $batch * Optional parameters to pass into the batch API. + * @param $redirect_callback + * (optional) Specify a function to be called to redirect to the progressive + * processing page. */ -function update_batch($start, $redirect = NULL, $url = NULL, $batch = array()) { +function update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $redirect_callback = NULL) { // During the update, bring the site offline so that schema changes do not // affect visiting users. $_SESSION['maintenance_mode'] = variable_get('maintenance_mode', FALSE); @@ -516,7 +519,7 @@ function update_batch($start, $redirect 'file' => 'includes/update.inc', ); batch_set($batch); - batch_process($redirect, $url); + batch_process($redirect, $url, $redirect_callback); } /**