Fix order by on is_primary.
authoreileen <emcnaughton@wikimedia.org>
Tue, 4 Sep 2018 00:09:16 +0000 (12:09 +1200)
committerSeamus Lee <seamuslee001@gmail.com>
Wed, 10 Oct 2018 21:21:59 +0000 (08:21 +1100)
As pointed out in https://lab.civicrm.org/dev/mail/issues/26 the order by is not the
correct format for order_by and has no effect. I tested to make sure it was not
some magic.

I opted for (implict) ASC as the order by for non sms is ASC and further down
processing seems to overwrite each row as it happens so primary later
would overwrite earlier

CRM/Mailing/BAO/Mailing.php

index e19f575baa6d32fd01557054c3528059a1340194..f81bcb1d057c2a5e2316c55f9324b463934970ba 100644 (file)
@@ -239,7 +239,7 @@ class CRM_Mailing_BAO_Mailing extends CRM_Mailing_DAO_Mailing {
         'phone_not_empty' => CRM_Utils_SQL_Select::fragment()->where("$entityTable.phone != ''"),
         'mailing_id' => CRM_Utils_SQL_Select::fragment()->where("mg.mailing_id = #mailingID"),
         'temp_contact_null' => CRM_Utils_SQL_Select::fragment()->where('temp.contact_id IS null'),
-        'order_by' => CRM_Utils_SQL_Select::fragment()->orderBy("$entityTable.is_primary = 1"),
+        'order_by' => CRM_Utils_SQL_Select::fragment()->orderBy("$entityTable.is_primary"),
       );
     }
     else {