From 93ff2b21ecc826196cf9762a9b5ad514e065d00e Mon Sep 17 00:00:00 2001 From: Rich Lott / Artful Robot Date: Tue, 15 Dec 2020 21:06:00 +0000 Subject: [PATCH] Fix lab issue 2254: cannot set is_bulkmail from UI --- CRM/Core/BAO/Email.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CRM/Core/BAO/Email.php b/CRM/Core/BAO/Email.php index aa0fdc956a..b4ed167c0f 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -44,13 +44,17 @@ class CRM_Core_BAO_Email extends CRM_Core_DAO_Email { $email->email = $strtolower($email->email); } - /* - * since we're setting bulkmail for 1 of this contact's emails, first reset all their other emails to is_bulkmail false - * We shouldn't set the current email to false even though we - * are about to reset it to avoid contaminating the changelog if logging is enabled. - * (only 1 email address can have is_bulkmail = true) - */ - if ($email->is_bulkmail && !empty($params['contact_id']) && !self::isMultipleBulkMail()) { + // + // Since we're setting bulkmail for 1 of this contact's emails, first reset + // all their other emails to is_bulkmail false. We shouldn't set the current + // email to false even though we are about to reset it to avoid + // contaminating the changelog if logging is enabled. (only 1 email + // address can have is_bulkmail = true) + // + // Note setting a the is_bulkmail to '' in $params results in $email->is_bulkmail === 'null'. + // @see https://lab.civicrm.org/dev/core/-/issues/2254 + // + if ($email->is_bulkmail == 1 && !empty($params['contact_id']) && !self::isMultipleBulkMail()) { $sql = " UPDATE civicrm_email SET is_bulkmail = 0 -- 2.25.1