From: eileen Date: Thu, 8 Feb 2018 01:07:07 +0000 (+1300) Subject: CRM-21749 fix obscure regression :Mailing api no longer respecting '_skip_evil_bao_au... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4ea375b48dad6694f64b0e3ee580bb0f460fb5cf;p=civicrm-core.git CRM-21749 fix obscure regression :Mailing api no longer respecting '_skip_evil_bao_auto_schedule_' --- diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index cbf7406678..5d954fdfb0 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -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. diff --git a/tests/phpunit/api/v3/MailingTest.php b/tests/phpunit/api/v3/MailingTest.php index efa5e658d7..36d970e7bd 100644 --- a/tests/phpunit/api/v3/MailingTest.php +++ b/tests/phpunit/api/v3/MailingTest.php @@ -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). */