CRM-16465 - Mailing BAO - Handle dedupe_email
authorTim Otten <totten@civicrm.org>
Fri, 15 May 2015 19:56:20 +0000 (12:56 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 15 May 2015 19:56:20 +0000 (12:56 -0700)
CRM/Mailing/BAO/Mailing.php
CRM/Mailing/BAO/MailingJob.php

index a0c7b9176e9491ea58e982dd2c6ea039a4ad129b..6719cae641db8beacc971f6de4e47fb027742d81 100644 (file)
@@ -1752,7 +1752,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
 
       // Populate the recipients.
       if (empty($params['_skip_evil_bao_auto_recipients_'])) {
-        self::getRecipients($job->id, $mailing->id, NULL, NULL, TRUE, FALSE);
+        self::getRecipients($job->id, $mailing->id, NULL, NULL, TRUE, $mailing->dedupe_email);
       }
     }
 
index e810c171467c0d0944a897dde4e6f957cfe29354..47b461948b6711209193aad357a371d412d5594c 100644 (file)
@@ -69,8 +69,14 @@ class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob {
     $job->is_test = $params['is_test'];
     $job->save();
     $mailing = new CRM_Mailing_BAO_Mailing();
-    $mailing->getRecipients($job->id, $params['mailing_id'], NULL, NULL, TRUE, FALSE);
-    return $job;
+    $mailing->id = $params['mailing_id'];
+    if ($mailing->id && $mailing->find(TRUE)) {
+      $mailing->getRecipients($job->id, $params['mailing_id'], NULL, NULL, TRUE, $mailing->dedupe_email);
+      return $job;
+    }
+    else {
+      throw new CRM_Core_Exception("Failed to create job: Unknown mailing ID");
+    }
   }
 
   /**