Index: includes/batch.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/batch.inc,v
retrieving revision 1.21
diff -u -r1.21 batch.inc
--- includes/batch.inc	20 Sep 2008 20:22:23 -0000	1.21
+++ includes/batch.inc	26 Sep 2008 22:09:58 -0000
@@ -11,14 +11,18 @@
 function _batch_page() {
   $batch =& batch_get();
 
-  // Retrieve the current state of batch from db.
-  if (isset($_REQUEST['id']) && $data = db_result(db_query("SELECT batch FROM {batch} WHERE bid = %d AND token = '%s'", $_REQUEST['id'], drupal_get_token($_REQUEST['id'])))) {
-    $batch = unserialize($data);
-  }
-  else {
+  if (!isset($_REQUEST['id'])) {
     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();
+
+  $batch = unserialize($batch);
+
   // Register database update for end of processing.
   register_shutdown_function('_batch_shutdown');
 
@@ -314,7 +318,9 @@
 
   // Cleanup the batch table and unset the global $batch variable.
   if ($batch['progressive']) {
-    db_query("DELETE FROM {batch} WHERE bid = %d", $batch['id']);
+    db_delete('batch')
+      ->condition('bid', $batch['id'])
+      ->execute();
   }
   $_batch = $batch;
   $batch = NULL;
@@ -358,6 +364,9 @@
  */
 function _batch_shutdown() {
   if ($batch = batch_get()) {
-    db_query("UPDATE {batch} SET batch = '%s' WHERE bid = %d", serialize($batch), $batch['id']);
+    db_update('batch')
+      ->fields(array('batch' => serialize($batch)))
+      ->condition('bid', $batch['id'])
+      ->execute();
   }
 }
