From 4ea375b48dad6694f64b0e3ee580bb0f460fb5cf Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 8 Feb 2018 14:07:07 +1300 Subject: [PATCH] CRM-21749 fix obscure regression :Mailing api no longer respecting '_skip_evil_bao_auto_schedule_' --- CRM/Mailing/BAO/Mailing.php | 2 +- tests/phpunit/api/v3/MailingTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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). */ -- 2.25.1