Index: includes/batch.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/batch.inc,v
retrieving revision 1.41
diff -u -p -r1.41 batch.inc
--- includes/batch.inc	9 Oct 2009 00:59:54 -0000	1.41
+++ includes/batch.inc	12 Oct 2009 02:34:04 -0000
@@ -17,6 +17,24 @@
  */
 
 /**
+ * Loads a batch from the database.
+ *
+ * @param $id
+ *  The ID of the batch to load.
+ * @return
+ *  An array representing the batch, if one 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);
+  }
+}
+
+/**
  * State-based dispatcher for the batch processing page.
  *
  * @see _batch_shutdown()
@@ -28,19 +46,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');
 
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.209
diff -u -p -r1.209 system.admin.inc
--- modules/system/system.admin.inc	9 Oct 2009 01:00:05 -0000	1.209
+++ modules/system/system.admin.inc	12 Oct 2009 02:34:05 -0000
@@ -1932,10 +1932,6 @@ function system_php() {
 function system_batch_page() {
   require_once DRUPAL_ROOT . '/includes/batch.inc';
   $output = _batch_page();
-  
-  // Use the same theme that the page that started the batch.
-  $batch = &batch_get();
-  $GLOBALS['custom_theme'] = $batch['theme'];
 
   if ($output === FALSE) {
     drupal_access_denied();
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.804
diff -u -p -r1.804 system.module
--- modules/system/system.module	10 Oct 2009 16:48:38 -0000	1.804
+++ modules/system/system.module	12 Oct 2009 02:34:05 -0000
@@ -893,6 +893,7 @@ function system_menu() {
   $items['batch'] = array(
     'page callback' => 'system_batch_page',
     'access callback' => TRUE,
+    'theme callback' => '_system_batch_theme',
     'type' => MENU_CALLBACK,
     'file' => 'system.admin.inc',
   );
@@ -900,6 +901,25 @@ function system_menu() {
 }
 
 /**
+ * Theme callback for the default batch page.
+ */
+function _system_batch_theme() {
+  // Retrieve the current state of the batch. In most cases the batch will not
+  // have been loaded yet.
+  $batch = &batch_get();
+  if (!$batch) {
+    require_once DRUPAL_ROOT . '/includes/batch.inc';
+    if (isset($_REQUEST['id'])) {
+      $batch = batch_load($_REQUEST['id']);
+    }
+  }
+  // Use the same theme as the page that started the batch.
+  if (!empty($batch['theme'])) {
+    return $batch['theme'];
+  }
+}
+
+/**
  * Implementation of hook_library().
  */
 function system_library() {
