From 426b9dec1980aa9bd39939a8d15abf3580dec3c6 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 21 May 2020 15:52:48 +1200 Subject: [PATCH] [REF] Minor code simiplification On digging the only reason for the array is to prevent duplicates. The function is passed do doesn't care how it's indexed so just use php array to prevent duplicates. Reduce brain hurt --- CRM/Contact/Form/Task/EmailTrait.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/CRM/Contact/Form/Task/EmailTrait.php b/CRM/Contact/Form/Task/EmailTrait.php index 2abc3f9132..59161e9ab1 100644 --- a/CRM/Contact/Form/Task/EmailTrait.php +++ b/CRM/Contact/Form/Task/EmailTrait.php @@ -360,6 +360,7 @@ trait CRM_Contact_Form_Task_EmailTrait { * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception * @throws \Civi\API\Exception\UnauthorizedException + * @throws \API_Exception */ public function postProcess() { $this->bounceIfSimpleMailLimitExceeded(count($this->_contactIds)); @@ -428,7 +429,6 @@ trait CRM_Contact_Form_Task_EmailTrait { // format contact details array to handle multiple emails from same contact $formattedContactDetails = []; - $tempEmails = []; foreach ($this->_contactIds as $key => $contactId) { // if we dont have details on this contactID, we should ignore // potentially this is due to the contact not wanting to receive email @@ -438,14 +438,10 @@ trait CRM_Contact_Form_Task_EmailTrait { $email = $this->_toContactEmails[$key]; // prevent duplicate emails if same email address is selected CRM-4067 // we should allow same emails for different contacts - $emailKey = "{$contactId}::{$email}"; - if (!in_array($emailKey, $tempEmails)) { - $tempEmails[] = $emailKey; - $details = $this->_contactDetails[$contactId]; - $details['email'] = $email; - unset($details['email_id']); - $formattedContactDetails[] = $details; - } + $details = $this->_contactDetails[$contactId]; + $details['email'] = $email; + unset($details['email_id']); + $formattedContactDetails["{$contactId}::{$email}"] = $details; } $contributionIds = []; -- 2.25.1