summaryrefslogtreecommitdiff
path: root/includes/form.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-03 20:17:46 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-03 20:17:46 +0000
commit0e161b661e2e87d11415093cc33803faf27d7182 (patch)
treeac63e311eb1e69a82ba32ce7fda199f5abdc150c /includes/form.inc
parent919d94be6eeaa0f4b455dfc12663527b9d08ef0a (diff)
downloadbrdo-0e161b661e2e87d11415093cc33803faf27d7182.tar.gz
brdo-0e161b661e2e87d11415093cc33803faf27d7182.tar.bz2
- Patch #555762 by gordon, sun | yched, chx, moshe weitzman, KiamLaLuno, lilou: improvements to batch API.
Diffstat (limited to 'includes/form.inc')
-rw-r--r--includes/form.inc20
1 files changed, 16 insertions, 4 deletions
diff --git a/includes/form.inc b/includes/form.inc
index 82d84b4f8..ce7171e28 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -2895,25 +2895,34 @@ 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 = 'batch', $redirect_callback = 'drupal_goto') {
$batch =& batch_get();
drupal_theme_initialize();
if (isset($batch)) {
// Add process information
- $url = isset($url) ? $url : 'batch';
$process_info = array(
'current_set' => 0,
'progressive' => TRUE,
- 'url' => isset($url) ? $url : 'batch',
+ 'url' => $url,
'source_page' => $_GET['q'],
'redirect' => $redirect,
'theme' => $GLOBALS['theme_key'],
+ 'redirect_callback' => $redirect_callback,
);
$batch += $process_info;
+ // The batch is now completely built. Allow other modules to make changes to the
+ // batch so that it is easier to reuse batch processes in other enviroments.
+ drupal_alter('batch', $batch);
+
if ($batch['progressive']) {
// Clear the way for the drupal_goto() redirection to the batch processing
// page, by saving and unsetting the 'destination', if there is any.
@@ -2948,7 +2957,10 @@ function batch_process($redirect = NULL, $url = NULL) {
// Set the batch number in the session to guarantee that it will stay alive.
$_SESSION['batches'][$batch['id']] = TRUE;
- drupal_goto($batch['url'], array('op' => 'start', 'id' => $batch['id']));
+ $function = $batch['redirect_callback'];
+ if (function_exists($function)) {
+ $function($batch['url'], array('op' => 'start', 'id' => $batch['id']));
+ }
}
else {
// Non-progressive execution: bypass the whole progressbar workflow