Index: modules/node/node.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v
retrieving revision 1.5
diff -u -r1.5 node.admin.inc
--- modules/node/node.admin.inc	27 Sep 2007 16:52:00 -0000	1.5
+++ modules/node/node.admin.inc	2 Oct 2007 16:09:16 -0000
@@ -82,27 +82,33 @@
   $operations = array(
     'publish' => array(
       'label' => t('Publish'),
-      'callback' => 'node_operations_publish',
+      'callback' => 'node_mass_update',
+      'callback arguments' => array('updates' => array('status' => 1)),
     ),
     'unpublish' => array(
       'label' => t('Unpublish'),
-      'callback' => 'node_operations_unpublish',
+      'callback' => 'node_mass_update',
+      'callback arguments' => array('updates' => array('status' => 0)),
     ),
     'promote' => array(
       'label' => t('Promote to front page'),
-      'callback' => 'node_operations_promote',
+      'callback' => 'node_mass_update',
+      'callback arguments' => array('updates' => array('status' => 1, 'promote' => 1)),
     ),
     'demote' => array(
       'label' => t('Demote from front page'),
-      'callback' => 'node_operations_demote',
+      'callback' => 'node_mass_update',
+      'callback arguments' => array('updates' => array('promote' => 0)),
     ),
     'sticky' => array(
       'label' => t('Make sticky'),
-      'callback' => 'node_operations_sticky',
+      'callback' => 'node_mass_update',
+      'callback arguments' => array('updates' => array('status' => 1, 'sticky' => 1)),
     ),
     'unsticky' => array(
       'label' => t('Remove stickiness'),
-      'callback' => 'node_operations_unsticky',
+      'callback' => 'node_mass_update',
+      'callback arguments' => array('updates' => array('sticky' => 0)),
     ),
     'delete' => array(
       'label' => t('Delete'),
@@ -113,48 +119,6 @@
 }
 
 /**
- * Callback function for admin mass publishing nodes.
- */
-function node_operations_publish($nodes) {
-  db_query('UPDATE {node} SET status = 1 WHERE nid IN('. db_placeholders($nodes) .')', $nodes);
-}
-
-/**
- * Callback function for admin mass unpublishing nodes.
- */
-function node_operations_unpublish($nodes) {
-  db_query('UPDATE {node} SET status = 0 WHERE nid IN('. db_placeholders($nodes) .')', $nodes);
-}
-
-/**
- * Callback function for admin mass promoting nodes.
- */
-function node_operations_promote($nodes) {
-  db_query('UPDATE {node} SET status = 1, promote = 1 WHERE nid IN('. db_placeholders($nodes) .')', $nodes);
-}
-
-/**
- * Callback function for admin mass demoting nodes.
- */
-function node_operations_demote($nodes) {
-  db_query('UPDATE {node} SET promote = 0 WHERE nid IN('. db_placeholders($nodes) .')', $nodes);
-}
-
-/**
- * Callback function for admin mass editing nodes to be sticky.
- */
-function node_operations_sticky($nodes) {
-  db_query('UPDATE {node} SET status = 1, sticky = 1 WHERE nid IN('. db_placeholders($nodes) .')',  $nodes);
-}
-
-/**
- * Callback function for admin mass editing nodes to remove stickiness.
- */
-function node_operations_unsticky($nodes) {
-  db_query('UPDATE {node} SET sticky = 0 WHERE nid IN('. db_placeholders($nodes) .')', $nodes);
-}
-
-/**
  * List node administration filters that can be applied.
  */
 function node_filters() {
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.888
diff -u -r1.888 node.module
--- modules/node/node.module	27 Sep 2007 12:56:04 -0000	1.888
+++ modules/node/node.module	2 Oct 2007 16:27:03 -0000
@@ -2570,3 +2570,85 @@
     }
   }
 }
+
+/**
+ * Make mass update of nodes, changing all nodes in the $nodes array
+ * to trigger the updates in the $updates array.
+ *
+ * IMPORTANT NOTE: This function is intended to work when called
+ * from a form submit handler! Calling it outside of the form submission
+ * process may not work correctly.
+ *
+ * @param array $nodes
+ *   Array of node nids to update.
+ * @param array $updates
+ *   Array of key/value pairs with node field names and the
+ *   value to update that field to.
+ * @param integer $limit
+ *   The number of nodes to process in each batch.
+ */
+function node_mass_update($nodes, $updates, $limit = 5) {
+  $nodes = array(1);
+  $batch = array(
+    'operations' => array(
+      array('node_mass_update_process', array($nodes, $updates, $limit))
+      ),
+    'finished' => 'node_mass_update_finished',
+    'title' => t('Processing'),
+    'progress_message' => t('Processed @current items out of @total items.'),
+    'error_message' => t('Content update has encountered an error.'),
+  );
+  batch_set($batch);
+  return;
+}
+
+/**
+ * Node Mass update Batch operation
+ */
+function node_mass_update_process($nodes, $updates, $limit, &$context) {
+  if (!isset($context['sandbox']['progress'])) {
+    $context['sandbox']['progress'] = 0;
+    $context['sandbox']['max'] = sizeof($nodes);
+    $context['sandbox']['nodes'] = $nodes;
+  }
+
+  // Process nodes by groups of $limit.
+  $count = min($limit, sizeof($context['sandbox']['nodes']));
+  for ($i = 1; $i <= $count; $i++) {
+    // For each nid, load the node, reset the values, and save it.
+    $nid = array_shift($context['sandbox']['nodes']);
+    $node = node_load($nid, NULL, TRUE);
+    foreach ($updates as $name => $value) {
+      $node->$name = $value;
+    }
+    node_save($node);
+
+    // Store result for post-processing in the finished callback.
+    $context['results'][] = $node->nid .' : '. $node->title;
+
+    // Update our progress information.
+    $context['sandbox']['progress']++;
+    $context['message'] = t('Processing %nid : %title', array('%nid' => $node->nid, '%title' => $node->title));
+  }
+
+  // Inform the batch engine that we are not finished,
+  // and provide an estimation of the completion level we reached.
+  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
+    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
+  }
+}
+
+/**
+ * Node Mass update Batch 'finished' callback.
+ */
+function node_mass_update_finished($success, $results, $operations) {
+  if (!$success) {
+    drupal_set_message(t('An error occurred and processing did not complete!'), 'error');
+  }
+  // Display a list of nodes processed whether there was success or failure.
+  // In the case of failure, it will be helpful to know which ones were
+  // successfully updated.
+  $message = t('@count items successfully processed:', array('@count' => count($results)));
+  $message .= theme('item_list', $results);
+  drupal_set_message($message);
+}
\ No newline at end of file
