Index: branches/5.2.x/core/units/mailing_lists/mailing_list_eh.php =================================================================== diff -u -N -r15461 -r15602 --- branches/5.2.x/core/units/mailing_lists/mailing_list_eh.php (.../mailing_list_eh.php) (revision 15461) +++ branches/5.2.x/core/units/mailing_lists/mailing_list_eh.php (.../mailing_list_eh.php) (revision 15602) @@ -1,6 +1,6 @@ Application->ConfigValue($variable_name); - if ($value === false) { + if ( $value === false ) { // ensure default value, when configuration variable is missing return 10; } - if (!$value) { + if ( !$value ) { // configuration variable found, but it's value is empty or zero return false; } @@ -288,7 +288,7 @@ $where_clause = Array ( 'Status NOT IN (' . MailingList::CANCELLED . ',' . MailingList::PROCESSED . ')', - '(EmailsQueued < EmailsTotal) OR (EmailsTotal = 0)', + '(EmailsQueuedTotal < EmailsTotal) OR (EmailsTotal = 0)', '`To` <> ""', ); @@ -297,21 +297,23 @@ WHERE (' . implode(') AND (', $where_clause) . ') ORDER BY ' . $id_field . ' ASC'; $mailing_lists = $this->Conn->Query($sql, $id_field); - if (!$mailing_lists) { - return ; + + if ( !$mailing_lists ) { + return; } // queue 10 emails per step summary from all mailing lists (FIFO logic) $to_queue = $this->_ensureDefault('MailingListQueuePerStep'); - if ($to_queue === false) { - return ; + + if ( $to_queue === false ) { + return; } $mailing_list_helper = $this->Application->recallObject('MailingListHelper'); /* @var $mailing_list_helper MailingListHelper */ foreach ($mailing_lists as $mailing_id => $mailing_data) { - if ($mailing_data['EmailsTotal'] == 0) { + if ( $mailing_data['EmailsTotal'] == 0 ) { // no work performed on this mailing list -> calculate totals $updated_fields = $mailing_list_helper->generateRecipients($mailing_id, $mailing_data); $updated_fields['Status'] = MailingList::PARTIALLY_PROCESSED; @@ -320,8 +322,9 @@ $this->Conn->doUpdate($updated_fields, $table_name, $id_field . ' = ' . $mailing_id); } - $emails = unserialize( $mailing_data['ToParsed'] ); - if (!$emails) { + $emails = unserialize($mailing_data['ToParsed']); + + if ( !$emails ) { continue; } @@ -337,14 +340,15 @@ // remove processed emails from array $to_queue -= $process_count; // decrement available for processing email count array_splice($emails, 0, $process_count); + $updated_fields = Array ( 'ToParsed' => serialize($emails), - 'EmailsQueued' => $mailing_data['EmailsQueued'] + $process_count, + 'EmailsQueuedTotal' => $mailing_data['EmailsQueuedTotal'] + $process_count, ); - $mailing_data = array_merge($mailing_data, $updated_fields); + $this->Conn->doUpdate($updated_fields, $table_name, $id_field . ' = ' . $mailing_id); - if (!$to_queue) { + if ( !$to_queue ) { // emails to be queued per step reached -> leave break; }