From ca7b04422ebb0bc59f94419cfe065ad7496be956 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 21 Jan 2022 12:08:28 -0500 Subject: [PATCH] SearchKit - Fix `checkEntityAccess` for anonymous users This function checks to see if a user has access to "get", but anonymous users might not even have access to check if they have access! --- Civi/Api4/Query/Api4SelectQuery.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Civi/Api4/Query/Api4SelectQuery.php b/Civi/Api4/Query/Api4SelectQuery.php index 82b835d5c2..f08bbbf6be 100644 --- a/Civi/Api4/Query/Api4SelectQuery.php +++ b/Civi/Api4/Query/Api4SelectQuery.php @@ -680,10 +680,16 @@ class Api4SelectQuery { return TRUE; } if (!isset($this->entityAccess[$entity])) { - $this->entityAccess[$entity] = (bool) civicrm_api4($entity, 'getActions', [ - 'where' => [['name', '=', 'get']], - 'select' => ['name'], - ])->first(); + try { + $this->entityAccess[$entity] = (bool) civicrm_api4($entity, 'getActions', [ + 'where' => [['name', '=', 'get']], + 'select' => ['name'], + ])->first(); + } + // Anonymous users might not even be allowed to use 'getActions' + catch (UnauthorizedException $e) { + $this->entityAccess[$entity] = FALSE; + } } return $this->entityAccess[$entity]; } -- 2.25.1