Commit dc00ac6d authored by totten's avatar totten

CRM-16373 - Mailer settings - Remove reliance on CRM_Core_BAO_ConfigSetting::create

parent 234d8f09
......@@ -2847,8 +2847,9 @@ WHERE civicrm_mailing_job.id = %1
// CRM-8460
$gotCronLock = FALSE;
if (property_exists($config, 'mailerJobsMax') && $config->mailerJobsMax && $config->mailerJobsMax > 0) {
$lockArray = range(1, $config->mailerJobsMax);
$mailerJobsMax = Civi::settings()->get('mailerJobsMax');
if (is_numeric($mailerJobsMax) && $mailerJobsMax > 0) {
$lockArray = range(1, $mailerJobsMax);
shuffle($lockArray);
// check if we are using global locks
......@@ -2875,7 +2876,7 @@ WHERE civicrm_mailing_job.id = %1
// load bootstrap to call hooks
// Split up the parent jobs into multiple child jobs
$mailerJobSize = (property_exists($config, 'mailerJobSize')) ? $config->mailerJobSize : NULL;
$mailerJobSize = Civi::settings()->get('mailerJobSize');
CRM_Mailing_BAO_MailingJob::runJobs_pre($mailerJobSize, $mode);
CRM_Mailing_BAO_MailingJob::runJobs(NULL, $mode);
CRM_Mailing_BAO_MailingJob::runJobs_post($mode);
......
......@@ -565,16 +565,14 @@ VALUES (%1, %2, %3, %4, %5, %6, %7)
// have been delivered in prior jobs
$isDelivered = TRUE;
// make sure that there's no more than $config->mailerBatchLimit mails processed in a run
// make sure that there's no more than $mailerBatchLimit mails processed in a run
$mailerBatchLimit = Civi::settings()->get('mailerBatchLimit');
while ($eq->fetch()) {
// if ( ( $mailsProcessed % 100 ) == 0 ) {
// CRM_Utils_System::xMemory( "$mailsProcessed: " );
// }
if (
$config->mailerBatchLimit > 0 &&
self::$mailsProcessed >= $config->mailerBatchLimit
) {
if ($mailerBatchLimit > 0 && self::$mailsProcessed >= $mailerBatchLimit) {
if (!empty($fields)) {
$this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
}
......@@ -798,8 +796,9 @@ VALUES (%1, %2, %3, %4, %5, %6, %7)
}
// If we have enabled the Throttle option, this is the time to enforce it.
if (isset($config->mailThrottleTime) && $config->mailThrottleTime > 0) {
usleep((int ) $config->mailThrottleTime);
$mailThrottleTime = Civi::settings()->get('mailThrottleTime');
if (!empty($mailThrottleTime)) {
usleep((int ) $mailThrottleTime);
}
}
......
......@@ -124,8 +124,8 @@ class CRM_Mailing_Page_Browse extends CRM_Core_Page {
// since we want only first function argument
$newArgs = $newArgs[0];
if (isset($_GET['runJobs']) || CRM_Utils_Array::value('2', $newArgs) == 'queue') {
$config = CRM_Core_Config::singleton();
CRM_Mailing_BAO_MailingJob::runJobs_pre($config->mailerJobSize);
$mailerJobSize = Civi::settings()->get('mailerJobSize');
CRM_Mailing_BAO_MailingJob::runJobs_pre($mailerJobSize);
CRM_Mailing_BAO_MailingJob::runJobs();
CRM_Mailing_BAO_MailingJob::runJobs_post();
}
......
......@@ -632,7 +632,7 @@ function civicrm_api3_mailing_send_test($params) {
$isComplete = FALSE;
$config = CRM_Core_Config::singleton();
$mailerJobSize = (property_exists($config, 'mailerJobSize')) ? $config->mailerJobSize : NULL;
$mailerJobSize = Civi::settings()->get('mailerJobSize');
while (!$isComplete) {
// Q: In CRM_Mailing_BAO_Mailing::processQueue(), the three runJobs*()
// functions are all called. Why does Mailing.send_test only call one?
......
......@@ -99,7 +99,7 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase {
public function testBasic() {
$this->createContactsInGroup(10, $this->_groupID);
$this->setSettings(array(
Civi::settings()->add(array(
'mailerBatchLimit' => 2,
));
$this->callAPISuccess('mailing', 'create', $this->_params);
......@@ -238,7 +238,7 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase {
$settings = array_merge($this->defaultSettings, $settings);
$this->createContactsInGroup($settings['recipients'], $this->_groupID);
$this->setSettings(CRM_Utils_Array::subset($settings, array(
Civi::settings()->add(CRM_Utils_Array::subset($settings, array(
'mailerBatchLimit',
'mailerJobsMax',
'mailThrottleTime',
......@@ -303,19 +303,6 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase {
return $recipients;
}
/**
* @param array $params
* - mailerBatchLimit
* - mailerJobSize
* - mailerJobsMax
* - mailThrottleTime
*/
protected function setSettings($params) {
// FIXME: These settings are not available via Setting API.
// When they become available, use that instead.
CRM_Core_BAO_ConfigSetting::create($params);
}
protected function cleanupMailingTest() {
$this->quickCleanup(array(
'civicrm_mailing',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment