? 462962_messaging_queue_limit_fix
? 462962_messaging_queue_limit_fix.patch
? adding_alter_function.patch
? messaging_phpmailer/PHPMailer
? messaging_phpmailer/PHPMailer_v5.1.zip
Index: messaging.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/messaging/messaging.module,v
retrieving revision 1.7.2.8.2.27.2.14
diff -u -p -r1.7.2.8.2.27.2.14 messaging.module
--- messaging.module	9 Apr 2010 17:35:27 -0000	1.7.2.8.2.27.2.14
+++ messaging.module	21 Jan 2011 17:34:59 -0000
@@ -359,10 +359,37 @@ function messaging_message_prepare($mess
  */
 function messaging_message_multisend($message, $info) {
   $success = TRUE;
+  $count = 0;
+  // The following will get the current overall process limits for the cron job
+  $limits = variable_get('messaging_current_process_limit');
   foreach ($message->destinations as $to) {
     // Be careful with the order of function && value, so they both are evaluated
+    $count = $count+1;
+    // This is a check to see if the process limits have been reached,
+    // If so, then it will update the entry in messaging_store with the
+    // updated array of destinations and will set a new array being multisend
+    // emails which will be all the emails sent during that process and the
+    // time when the job completed
+    if (($count > $limits['max'] && $limits['max']) || time() > $limits['time']){
+      $sent = array_splice($message->destinations,0,($count-1));
+      $params['destinations'] = $message->destinations;
+      $params['multisent'] = $message->multisent;
+      $params['multisent'][] = array($sent, time());
+      $success = false;
+      $message->params = $params ? $params : NULL;
+      drupal_write_record('messaging_store', $message,'mqid');
+      $limits['time']=1;
+      variable_set('messaging_current_process_limit',$limits);
+      break;
+    }
     $success = messaging_message_send_out($to, $message, $message->method) && $success;
   }
+
+  // Update global variable for max number of messages sent.
+  // This is done because everytime a new multisend comes through
+  // it will fist look to see if any limits have been reached before doing anything.
+  $limits['max'] -= ($count-1);
+  variable_set('messaging_current_process_limit',$limits);
   // If sent, set time. If failed force logging.
   $success ? ($message->sent = time()) : ($message->log = 1);
   $message->success = $success;
@@ -716,6 +743,10 @@ function messaging_message_render($messa
   }
   // Render separately subject and body info, adding default parameters
   $info += array('glue' => '', 'subject_glue' => '', 'filter' => NULL);
+  foreach(module_implements('messaging_render_alter') as $module) {
+    $callback = $module .'_messaging_render_alter';
+    $callback($message, $info);
+  }
   $message->subject = messaging_check_subject(messaging_text_render($message->subject, $info['subject_glue']));
   $message->body = messaging_text_render($message->body, $info['glue'], $info['filter']); 
   $message->rendered = 1;  
Index: messaging.store.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/messaging/Attic/messaging.store.inc,v
retrieving revision 1.1.2.4.2.9.2.2
diff -u -p -r1.1.2.4.2.9.2.2 messaging.store.inc
--- messaging.store.inc	11 Nov 2009 18:07:24 -0000	1.1.2.4.2.9.2.2
+++ messaging.store.inc	21 Jan 2011 17:34:59 -0000
@@ -42,6 +42,12 @@ function messaging_store_queue_process($
   // Processing loop. Will stop when we run out of rows or reach time / messages limit
   $count = 0;
   $max = !empty($limit['message']) ? $limit['message'] : 0;
+  // A new variable had to be set messaging_current_process_limit
+  // will set the overall beginning time and max msgs of the current cron process.
+  // This was done specifically for the loop inside of the
+  // multisend function when sending large number of emails as a broadcast.
+  $limit['max'] = $max;
+  variable_set('messaging_current_process_limit', $limit);
   do {
     $step = $max ? min(MESSAGING_STEP_ROWS, $max - $count) : MESSAGING_STEP_ROWS;
     $number = messaging_store_queue_process_step($step, $limit['time']);
@@ -241,11 +247,14 @@ function messaging_store_sent($mqid, $er
     // First delete the ones that are not for logging, then mark as sent
     db_query("DELETE FROM {messaging_store} WHERE log = 0 AND ".implode(' AND ', $where) , $args);
     $sent = time();
-  }
 
-  // Now unmark the rest for queue processing, as logs
-  $args = array_merge(array($sent), $args);
-  db_query("UPDATE {messaging_store} SET queue = 0, cron = 0, log = 1, sent = %d WHERE ".implode(' AND ', $where), $args);
+    // Now unmark the rest for queue processing, as logs
+    // This had to be moved inside if statement because multisend messages that
+    // were still queued but had reached a time limit or a msg limit
+    // were getting deleted therefore not getting to every recipient
+    $args = array_merge(array($sent), $args);
+    db_query("UPDATE {messaging_store} SET queue = 0, cron = 0, log = 1, sent = %d WHERE ".implode(' AND ', $where), $args);
+  }
 }
 
 /**
