From 6d5ef367201cd12287356f692740c6c538cbbc38 Mon Sep 17 00:00:00 2001 From: Rich Lott / Artful Robot Date: Wed, 20 Sep 2023 15:11:13 +0100 Subject: [PATCH] Stop saying N contacts removed when they were already removed. --- CRM/Contact/BAO/GroupContact.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/BAO/GroupContact.php b/CRM/Contact/BAO/GroupContact.php index 114eba98e5..56182d0ee8 100644 --- a/CRM/Contact/BAO/GroupContact.php +++ b/CRM/Contact/BAO/GroupContact.php @@ -201,14 +201,15 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact implemen CRM_Contact_BAO_GroupContactCache::invalidateGroupContactCache($groupId); } else { + // 'Removed' means we add a history record and ensure the GroupContact record exists with a 'Removed' status. $groupContact = new CRM_Contact_DAO_GroupContact(); $groupContact->group_id = $groupId; $groupContact->contact_id = $contactId; - // check if the selected contact id already a member, or if this is + // check if the selected contact is already listed as Removed // an opt-out of a smart group. // if not a member remove to groupContact else keep the count of contacts that are not removed - if ($groupContact->find(TRUE) || $group->saved_search_id) { - // remove the contact from the group + if (($groupContact->find(TRUE) || $group->saved_search_id) && $groupContact->status !== $status) { + // remove the contact from the group. $numContactsRemoved++; } else { -- 2.25.1