'mailerJobSize' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'mailerJobsMax' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'verpSeparator' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
+ // dev/core#1768 Make this interval configurable.
+ 'civimail_sync_interval' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'replyTo' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
];
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - CiviMail'));
$this->addFormRule(['CRM_Admin_Form_Setting_Mail', 'formRule']);
-
parent::buildQuickForm();
}
*/
public static function formRule($fields) {
$errors = [];
-
if (CRM_Utils_Array::value('mailerJobSize', $fields) > 0) {
if (CRM_Utils_Array::value('mailerJobSize', $fields) < 1000) {
$errors['mailerJobSize'] = ts('The job size must be at least 1000 or set to 0 (unlimited).');
$errors['mailerJobSize'] = ts('A job size smaller than the batch limit will negate the effect of the batch limit.');
}
}
-
+ if (CRM_Utils_Array::value('civimail_sync_interval', $fields) < 1) {
+ $errors['civimail_sync_interval'] = ts('Error - the synchronization interval must be at least 1');
+ }
return empty($errors) ? TRUE : $errors;
}
$now = time();
$params = [];
$count = 0;
+ // dev/core#1768 Get the mail sync interval.
+ $mail_sync_interval = Civi::settings()->get('civimail_sync_interval');
while ($recipients->fetch()) {
// CRM-18543: there are situations when both the email and phone are null.
// Skip the recipient in this case.
$recipients->phone_id,
];
$count++;
- if ($count % CRM_Mailing_Config::BULK_MAIL_INSERT_COUNT == 0) {
+ // dev/core#1768 Mail sync interval is now configurable.
+ if ($count % $mail_sync_interval == 0) {
CRM_Mailing_Event_BAO_Queue::bulkCreate($params, $now);
$count = 0;
$params = [];
$returnProperties = $mailing->getReturnProperties();
$params = $targetParams = $deliveredParams = [];
$count = 0;
+ // dev/core#1768 Get the mail sync interval.
+ $mail_sync_interval = Civi::settings()->get('civimail_sync_interval');
$retryGroup = FALSE;
// CRM-15702: Sending bulk sms to contacts without e-mail address fails.
$targetParams[] = $field['contact_id'];
$count++;
- if ($count % CRM_Mailing_Config::BULK_MAIL_INSERT_COUNT == 0) {
+ // dev/core#1768 Mail sync interval is now configurable.
+ if ($count % $mail_sync_interval == 0) {
$this->writeToDB(
$deliveredParams,
$targetParams,
// special value for mail bulk inserts to avoid
// potential duplication, assuming a smaller number reduces number of queries
// by some factor, so some tradeoff. CRM-8678
+ // dev/core#1768 Remove this after Dec 2020.
+ // Replaced with civimail_sync_interval.
const BULK_MAIL_INSERT_COUNT = 10;
}
'description' => ts('If checked, mailings will have open tracking enabled by default.'),
'help_text' => NULL,
],
+ // dev/cor#1768 Allow mailer sync interval to be configured by the
+ // adminstrator.
+ 'civimail_sync_interval' => [
+ 'group_name' => 'Mailing Preferences',
+ 'group' => 'mailing',
+ 'name' => 'civimail_sync_interval',
+ 'type' => 'Integer',
+ 'quick_form_type' => 'Element',
+ 'html_type' => 'text',
+ 'html_attributes' => [
+ 'size' => 4,
+ 'maxlength' => 8,
+ ],
+ 'default' => 10,
+ 'title' => ts('Database Update Frequency'),
+ 'add' => '5.28',
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'description' => ts('The frequency that CiviMail updates its sent mail database.'),
+ 'help_text' => 'CiviMail records email sent at the frequency you specify. If you set it to 1, it will update the database every time it sends an email. This ensures that emails are not resent if the batch job fails, but this may cause a performance hit, particularly for large jobs.',
+ ],
];
</p><p>
{ts}"user and user admin" only means that only users that received the mailing or administrators can view the content of this email as a web page; the recipients will have to log in to be able to view the message{/ts}
<p></p>
+{htxt id="mailing-sync-interval-title"}
+ {ts}Sync Interval{/ts}
+{ts}"civimail_sync_interval" specifies how frequently CiviMail records which emails it has sent. A value of 1 means that it updates the database with every email sent, but this may have a performance hit.{/ts}:
+<p></p>
{/htxt}