From: Coleman Watts Date: Wed, 1 Apr 2015 23:15:28 +0000 (-0400) Subject: CRM-16081 - Fix unsubscribe error if groups are empty X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3921b55db2b7a756af7492491410187d5c7ae854;p=civicrm-core.git CRM-16081 - Fix unsubscribe error if groups are empty --- diff --git a/CRM/Mailing/Event/BAO/Unsubscribe.php b/CRM/Mailing/Event/BAO/Unsubscribe.php index 87232388de..10287840cf 100755 --- a/CRM/Mailing/Event/BAO/Unsubscribe.php +++ b/CRM/Mailing/Event/BAO/Unsubscribe.php @@ -230,6 +230,10 @@ WHERE email = %2 if (!empty($base_group_ids)) { $baseGroupClause = "OR $group.id IN(" . implode(', ', $base_group_ids) . ")"; } + $groupIdClause = ''; + if ($group_ids || $base_group_ids) { + $groupIdClause = "AND $group.id IN (" . implode(', ', array_merge($group_ids, $base_group_ids)) . ")"; + } $do->query(" SELECT $group.id as group_id, $group.title as title, @@ -237,8 +241,8 @@ WHERE email = %2 FROM $group LEFT JOIN $gc ON $gc.group_id = $group.id - WHERE $group.id IN (" . implode(', ', array_merge($group_ids, $base_group_ids)) . ") - AND $group.is_hidden = 0 + WHERE $group.is_hidden = 0 + $groupIdClause AND ($group.saved_search_id is not null OR ($gc.contact_id = $contact_id AND $gc.status = 'Added')