From 0070596d1817305419fce938b1a4df3be472dd1c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 9 Feb 2021 20:21:57 -0500 Subject: [PATCH] Fix angular error when user is not logged in. --- CRM/Core/BAO/Dashboard.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php index 6246590ca9..80f8b43e34 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -42,12 +42,13 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { * array of dashlets */ public static function getContactDashlets() { - if (!isset(Civi::$statics[__CLASS__][__FUNCTION__])) { - Civi::$statics[__CLASS__][__FUNCTION__] = []; + $cid = CRM_Core_Session::getLoggedInContactID(); + if ($cid && !isset(Civi::$statics[__CLASS__][__FUNCTION__][$cid])) { + Civi::$statics[__CLASS__][__FUNCTION__][$cid] = []; $params = [ 'select' => ['*', 'dashboard_contact.*'], 'join' => [ - ['DashboardContact AS dashboard_contact', FALSE, ['dashboard_contact.contact_id', '=', CRM_Core_Session::getLoggedInContactID()]], + ['DashboardContact AS dashboard_contact', FALSE, ['dashboard_contact.contact_id', '=', $cid]], ], 'where' => [ ['domain_id', '=', 'current_domain'], @@ -66,11 +67,11 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { foreach ($results as $item) { if ($item['is_active'] && self::checkPermission($item['permission'], $item['permission_operator'])) { - Civi::$statics[__CLASS__][__FUNCTION__][] = $item; + Civi::$statics[__CLASS__][__FUNCTION__][$cid][] = $item; } } } - return Civi::$statics[__CLASS__][__FUNCTION__]; + return Civi::$statics[__CLASS__][__FUNCTION__][$cid] ?? []; } /** -- 2.25.1