Skip to content

Commit

Permalink
Fix: Email processing occurs in the wrong order.
Browse files Browse the repository at this point in the history
The purpose of the email queue is to allow batch processing emails to speed up web page response.

Our aim should be to ensure the email table is as close to empty at all times,
(if cron jobs are not used, we try to clear the table at the end of the web page request)

Therefore:

a) There's no need to define a custom sort order for the table. In the ideal world, where the table is empty, the sort order is going to be irrelevant

b) Emails should be sent in the order they are generated. Therefore, they should always be processed in ASCending order.

After this, I plan on looking at how we handle emails that previously errored to ensure that users are notified of problems in some way, and we avoid performance issues, as email troubleshooting is one of our more popular support issues with end users
  • Loading branch information
mantis committed Jul 14, 2014
1 parent fd4c97b commit 13c2096
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/email_queue_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,12 @@ function email_queue_delete( $p_email_id ) {

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

$t_query = 'SELECT email_id FROM ' . $t_email_table . ' ORDER BY email_id ' . $p_sort_order;
$t_query = 'SELECT email_id FROM ' . $t_email_table . ' ORDER BY email_id ASC';
$t_result = db_query_bound( $t_query );

$t_ids = array();
Expand Down

0 comments on commit 13c2096

Please sign in to comment.