From 0737f33066a72999f22124131b845abf3da614a8 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Thu, 29 Nov 2012 11:15:21 +0100 Subject: [PATCH] Make email_send_all() send older queued messages first 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 --- core/email_api.php | 2 +- core/email_queue_api.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/email_api.php b/core/email_api.php index 0b2bffa819..7e31ea5859 100644 --- a/core/email_api.php +++ b/core/email_api.php @@ -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); diff --git a/core/email_queue_api.php b/core/email_queue_api.php index 76fe5fd73b..b8d980c6b5 100644 --- a/core/email_queue_api.php +++ b/core/email_queue_api.php @@ -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();