summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-02 15:57:33 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-02 15:57:33 +0000
commit032fe0a66d97469609f5fe7cc6be242765042a63 (patch)
treee4c3fb97ff1319a39b6086f29673d357f3f0fcfe /includes
parent4363c22b0398472b62a87f9f5c2b7ed88a393a77 (diff)
downloadbrdo-032fe0a66d97469609f5fe7cc6be242765042a63.tar.gz
brdo-032fe0a66d97469609f5fe7cc6be242765042a63.tar.bz2
#539022 follow-up by David_Rothstein: Batch API should use the current theme to run the batches.
Diffstat (limited to 'includes')
-rw-r--r--includes/batch.inc36
1 files changed, 26 insertions, 10 deletions
diff --git a/includes/batch.inc b/includes/batch.inc
index 9a4f8271f..1efeb6470 100644
--- a/includes/batch.inc
+++ b/includes/batch.inc
@@ -17,6 +17,26 @@
*/
/**
+ * Loads a batch from the database.
+ *
+ * @param $id
+ * The ID of the batch to load. When a progressive batch is being processed,
+ * the relevant ID is found in $_REQUEST['id'].
+ * @return
+ * An array representing the batch, or FALSE if no batch was found.
+ */
+function batch_load($id) {
+ $batch = db_query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array(
+ ':bid' => $id,
+ ':token' => drupal_get_token($id),
+ ))->fetchField();
+ if ($batch) {
+ return unserialize($batch);
+ }
+ return FALSE;
+}
+
+/**
* State-based dispatcher for the batch processing page.
*
* @see _batch_shutdown()
@@ -28,19 +48,15 @@ function _batch_page() {
return FALSE;
}
- // Retrieve the current state of batch from db.
- $batch = db_query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array(
- ':bid' => $_REQUEST['id'],
- ':token' => drupal_get_token($_REQUEST['id']))
- )->fetchField();
-
+ // Retrieve the current state of the batch.
if (!$batch) {
- drupal_set_message(t('No active batch.'), 'error');
- drupal_goto();
+ $batch = batch_load($_REQUEST['id']);
+ if (!$batch) {
+ drupal_set_message(t('No active batch.'), 'error');
+ drupal_goto();
+ }
}
- $batch = unserialize($batch);
-
// Register database update for the end of processing.
register_shutdown_function('_batch_shutdown');