From 1db9fca15b323ae4e2d00cd786c89b3505584b95 Mon Sep 17 00:00:00 2001 From: mark burdett Date: Tue, 12 Jul 2016 21:09:07 -0700 Subject: [PATCH] CRM-19070 - CiviMail - Schedule job after recipients have been populated --- CRM/Mailing/BAO/Mailing.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index e09c1fe591..9b80eda370 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -1760,7 +1760,8 @@ ORDER BY civicrm_email.is_bulkmail DESC $job->is_test = 0; if (!$job->find(TRUE)) { - $job->scheduled_date = $params['scheduled_date']; + // Don't schedule job until we populate the recipients. + $job->scheduled_date = NULL; $job->save(); } @@ -1770,6 +1771,9 @@ ORDER BY civicrm_email.is_bulkmail DESC $mode = $mailing->sms_provider_id ? 'sms' : NULL; self::getRecipients($job->id, $mailing->id, TRUE, $mailing->dedupe_email, $mode); } + // Schedule the job now that it has recipients. + $job->scheduled_date = $params['scheduled_date']; + $job->save(); } return $mailing; -- 2.25.1