From 60b7c220b443255ab6097da77b132d84083a8b0b Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Fri, 29 Sep 2023 16:03:31 +0100 Subject: [PATCH] Fix ACL edge case --- CRM/ACL/BAO/ACL.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index dd39cce679..944faaf3de 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -513,7 +513,7 @@ SELECT g.* "; $dao = CRM_Core_DAO::executeQuery($query); $foundGroupIDs = []; - $groupContactCacheClause = FALSE; + $groupContactCacheClause = ''; while ($dao->fetch()) { $foundGroupIDs[] = $dao->id; if (($dao->saved_search_id || $dao->children || $dao->parents)) { @@ -524,7 +524,7 @@ SELECT g.* } } - if ($groupIDs) { + if ($foundGroupIDs) { return "( `contact_a`.id $operation ( SELECT contact_id FROM civicrm_group_contact WHERE group_id IN (" . implode(', ', $foundGroupIDs) . ") AND status = 'Added' @@ -532,7 +532,12 @@ SELECT g.* ) )"; } - return ''; + else { + // Edge case avoiding SQL syntax error if no $foundGroupIDs + return "( + `contact_a`.id $operation (0) + )"; + } } public static function getObjectTableOptions(): array { -- 2.25.1