From ad1df64849fb67a90d6e79244849fe876002e195 Mon Sep 17 00:00:00 2001
From: Bradley M. Froehle <brad.froehle@gmail.com>
Date: Fri, 18 Feb 2011 00:53:16 -0800
Subject: [PATCH] 1009716 - fix batch error messages.

---
 includes/batch.inc |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git includes/batch.inc includes/batch.inc
index 1510a62..5f25554 100644
--- includes/batch.inc
+++ includes/batch.inc
@@ -48,12 +48,21 @@ function _batch_page() {
     return FALSE;
   }
 
+  $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
+
   // Retrieve the current state of the batch.
   if (!$batch) {
     $batch = batch_load($_REQUEST['id']);
     if (!$batch) {
-      drupal_set_message(t('No active batch.'), 'error');
-      drupal_goto();
+      if ($op == 'do') {
+        // JavaScript-based progress page callback.
+        drupal_json_output(array('status' => FALSE, 'data' => t('No active batch.')));
+        return;
+      }
+      else {
+        drupal_set_message(t('No active batch.'), 'error');
+        drupal_goto();
+      }
     }
   }
 
@@ -69,7 +78,6 @@ function _batch_page() {
     }
   }
 
-  $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
   $output = NULL;
   switch ($op) {
     case 'start':
-- 
1.7.3.5

