// 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
// 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);
// 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);
}
}
// 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);
}
}
// 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();
}
$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?
public function testBasic() {
$this->createContactsInGroup(10, $this->_groupID);
- $this->setSettings(array(
+ Civi::settings()->add(array(
'mailerBatchLimit' => 2,
));
$this->callAPISuccess('mailing', 'create', $this->_params);
$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',
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',