CRM-21749 fix obscure regression :Mailing api no longer respecting '_skip_evil_bao_au...
authoreileen <emcnaughton@wikimedia.org>
Thu, 8 Feb 2018 01:07:07 +0000 (14:07 +1300)
committereileen <emcnaughton@wikimedia.org>
Thu, 8 Feb 2018 01:10:54 +0000 (14:10 +1300)
CRM/Mailing/BAO/Mailing.php
tests/phpunit/api/v3/MailingTest.php

index cbf740667841335ab660d525df7df5137bc7aa37..5d954fdfb0ce1a598a625176625eff7ab4b4c81a 100644 (file)
@@ -1630,7 +1630,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
 
     // 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.
index efa5e658d762c7022e757f1a3097305fcc39c551..36d970e7bdc70961d864087f93b37a35596b3405 100644 (file)
@@ -85,6 +85,18 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     $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).
    */