// Create parent job if not yet created.
// Condition on the existence of a scheduled date.
- if (!empty($params['scheduled_date']) && $params['scheduled_date'] != 'null') {
+ if (!empty($params['scheduled_date']) && $params['scheduled_date'] != 'null' && empty($params['_skip_evil_bao_auto_schedule_'])) {
$job = new CRM_Mailing_BAO_MailingJob();
$job->mailing_id = $mailing->id;
// If we are creating a new Completed mailing (e.g. import from another system) set the job to completed.
$this->getAndCheck($this->_params, $result['id'], 'mailing');
}
+ /**
+ * Tes that the parameter _skip_evil_bao_auto_schedule_ is respected & prevents jobs being created.
+ */
+ public function testSkipAutoSchedule() {
+ $this->callAPISuccess('Mailing', 'create', array_merge($this->_params, [
+ '_skip_evil_bao_auto_schedule_' => TRUE,
+ 'scheduled_date' => 'now'
+ ]));
+ $this->callAPISuccessGetCount('Mailing', [], 1);
+ $this->callAPISuccessGetCount('MailingJob', [], 0);
+ }
+
/**
* Create a completed mailing (e.g when importing from a provider).
*/