From 11ddfae4bee239b6744c1d71da019ee7a4c528a1 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Mon, 3 Aug 2015 11:10:31 +0530 Subject: [PATCH] CRM-16945 fix - Groups tab shows duplicate groups when a contact has been hard-added to a smart gorup or paarent group https://issues.civicrm.org/jira/browse/CRM-16945 --- CRM/Contact/BAO/GroupContact.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/BAO/GroupContact.php b/CRM/Contact/BAO/GroupContact.php index 2a564f3feb..23a96a75ae 100644 --- a/CRM/Contact/BAO/GroupContact.php +++ b/CRM/Contact/BAO/GroupContact.php @@ -351,7 +351,7 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { civicrm_subscription_history.method as method'; } - $where = " WHERE contact_a.id = %1 AND civicrm_group.is_active = 1 AND civicrm_group.saved_search_id IS NULL"; + $where = " WHERE contact_a.id = %1 AND civicrm_group.is_active = 1"; if ($excludeHidden) { $where .= " AND civicrm_group.is_hidden = 0 "; @@ -381,6 +381,10 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { $from = CRM_Contact_BAO_Query::fromClause($tables); + //CRM-16945: seems hackish but as per CRM-16483 of using group criteria for Search Builder it is mandatory + //to include group_contact_cache clause when group table is present, so following code remove duplicacy + $from = str_replace("OR civicrm_group.id = civicrm_group_contact_cache.group_id", '', $from); + $where .= " AND $permission "; if ($onlyPublicGroups) { -- 2.25.1