Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 37a2fee2fb1a
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 17858aeea2ac
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 29, 2012

  1. Copy the full SHA
    e750915 View commit details
  2. 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
    dregad committed Nov 29, 2012
    Copy the full SHA
    17858ae View commit details
Showing with 9 additions and 6 deletions.
  1. +6 −4 core/email_api.php
  2. +3 −2 core/email_queue_api.php
10 changes: 6 additions & 4 deletions core/email_api.php
Original file line number Diff line number Diff line change
@@ -856,15 +856,17 @@ function email_store( $p_recipient, $p_subject, $p_message, $p_headers = null )
}

/**
* This function sends all the emails that are stored in the queue. If a failure occurs, then the
* function exists. This function will be called after storing emails in case of synchronous
* emails, or will be called from a cronjob in case of asynchronous emails.
* This function sends all the emails that are stored in the queue.
* It will be called
* - immediately after queueing messages in case of synchronous emails
* - from a cronjob in case of asynchronous emails
* If a failure occurs, then the function exits.
* @todo In case of synchronous email sending, we may get a race condition where two requests send the same email.
* @param bool $p_delete_on_failure indicates whether to remove email from queue on failure (default false)
* @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);
5 changes: 3 additions & 2 deletions core/email_queue_api.php
Original file line number Diff line number Diff line change
@@ -183,12 +183,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( 'email' );

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