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();