From: Jon Goldberg Date: Fri, 29 Dec 2023 21:05:49 +0000 (-0500) Subject: Don't try to insert 0 as a user_id to ACL contact cache X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d3cb72a16deb30b4210d44faf4b87ad75d2b81bf;p=civicrm-core.git Don't try to insert 0 as a user_id to ACL contact cache --- diff --git a/CRM/Contact/BAO/Contact/Permission.php b/CRM/Contact/BAO/Contact/Permission.php index db3ff979f1..d839e1cf3c 100644 --- a/CRM/Contact/BAO/Contact/Permission.php +++ b/CRM/Contact/BAO/Contact/Permission.php @@ -294,8 +294,8 @@ AND $operationClause // Add in a row for the logged in contact. Do not try to combine with the above query or an ugly OR will appear in // the permission clause. - if (CRM_Core_Permission::check('edit my contact') || - ($type == CRM_Core_Permission::VIEW && CRM_Core_Permission::check('view my contact'))) { + if ($userID && (CRM_Core_Permission::check('edit my contact') || + ($type == CRM_Core_Permission::VIEW && CRM_Core_Permission::check('view my contact')))) { if (!CRM_Core_DAO::singleValueQuery(" SELECT count(*) FROM civicrm_acl_contact_cache WHERE user_id = %1 AND contact_id = %1 AND operation = '{$operation}' LIMIT 1", $queryParams)) { CRM_Core_DAO::executeQuery("INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation ) VALUES(%1, %1, '{$operation}')", $queryParams);