? 218066-15.crosspost.patch
? crosspost_1.patch
? custom-priority-26.patch
? mail_cleanup_sans_whitespace.patch
? xpost.patch
? includes/mail.inc.patched
Index: includes/admin.batch_confirm.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/includes/admin.batch_confirm.inc,v
retrieving revision 1.1
diff -u -p -r1.1 admin.batch_confirm.inc
--- includes/admin.batch_confirm.inc	24 Apr 2010 01:58:18 -0000	1.1
+++ includes/admin.batch_confirm.inc	28 Apr 2010 08:42:32 -0000
@@ -32,32 +32,23 @@
  *        be set to 1 when all rows have been processed.
  */
 function _project_issue_batch_update($sql, $base_arguments, &$context = array()) {
-  $last_nid = 0;
-  $first_nid = 0;
-  if (!isset($context['sandbox']['min'])) {
-    // Avoid COUNT(*) like hell.
+  if (!isset($context['sandbox']['current'])) {
+    // Avoid COUNT(*) like hell. Or not.
     $context['sandbox']['max'] = db_result(db_query('SELECT MAX(nid) FROM {project_issues}'));
-    // We will use > so use - 1 when choosing the smallest nid.
-    $context['sandbox']['min'] = db_result(db_query('SELECT MIN(nid) - 1 FROM {project_issues}'));
-    $context['sandbox']['current'] = $context['sandbox']['min'];
+    $context['sandbox']['current'] = 0;
   }
   $arguments = $base_arguments;
-  // MySQL does not support LIMIT & IN/ALL/ANY/SOME subquery so we do the hard
-  // work ourselves: find 100 nids and record the first and the last.
-  $results = db_query_range('SELECT nid FROM {project_issues} WHERE nid > %d ORDER BY nid ASC', $context['sandbox']['current'], 0, 100);
-  while ($node = db_fetch_object($results)) {
-    if (!isset($first_nid)) {
-      $first_nid = $node->nid;
-    }
-    $last_nid = $node->nid;
-  }
-  $arguments[] = $first_nid;
+
+  $limit = 500;
+
+  $last_nid = $context['sandbox']['current'] + $limit;
+  $arguments[] = $context['sandbox']['current'];
   $arguments[] = $last_nid;
   db_query($sql, $arguments);
   // Note that we do not count exactly as there can be holes. That's still
   // better than running COUNT() on large datasets.
   if ($last_nid < $context['sandbox']['max']) {
-    $context['finished'] = ($last_nid - $context['sandbox']['min']) / ($context['sandbox']['max'] - $context['sandbox']['min']);
+    $context['finished'] = $last_nid / $context['sandbox']['max'];
     $context['sandbox']['current'] = $last_nid;
   }
   else {
