Skip to content

Commit

Permalink
Make email_send_all() send older queued messages first
Browse files Browse the repository at this point in the history
To achieve this, a new optional parameter was added to function
email_queue_get_ids() to specify the desired sort order (defaults to
'DESC' to ensure no change in behavior).

email_send_all() now retrieves the list of emails to send in ascending
order.

Fixes #15248
  • Loading branch information
dregad committed Nov 29, 2012
1 parent 3be57b7 commit 0737f33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/email_api.php
Expand Up @@ -845,7 +845,7 @@ function email_store( $p_recipient, $p_subject, $p_message, $p_headers = null )
* @return null
*/
function email_send_all($p_delete_on_failure = false) {
$t_ids = email_queue_get_ids();
$t_ids = email_queue_get_ids('ASC');

$t_emails_recipients_failed = array();
$t_start = microtime(true);
Expand Down
5 changes: 3 additions & 2 deletions core/email_queue_api.php
Expand Up @@ -169,12 +169,13 @@ function email_queue_delete( $p_email_id ) {

/**
* Get array of email queue id's
* @param string $p_sort_order 'ASC' or 'DESC' (defaults to DESC)
* @return array
*/
function email_queue_get_ids() {
function email_queue_get_ids( $p_sort_order = 'DESC' ) {
$t_email_table = db_get_table( 'mantis_email_table' );

$query = 'SELECT email_id FROM ' . $t_email_table . ' ORDER BY email_id DESC';
$query = "SELECT email_id FROM $t_email_table ORDER BY email_id $p_sort_order";
$result = db_query_bound( $query );

$t_ids = array();
Expand Down

0 comments on commit 0737f33

Please sign in to comment.