From b32b84b64515669d6f566d77673b78e08d2a0864 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Fri, 19 Apr 2024 13:51:52 +0200 Subject: [PATCH] Fix exception for anonymous viewers on dashboard query panels with user-specific data Summary: When a viewer is not logged in and opens a public dashboard which embeds a query panel whose data requires a Current Viewer context (e.g. assigned or authored tasks, or joined projects), do not throw an exception but show an explanatory placeholder sentence (similar to already existing 'No tasks found.' or 'No documents found.' strings). ``` EXCEPTION: (Exception) Query "assigned" is unknown to application search engine "ManiphestTaskSearchEngine"! at [/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php:80] EXCEPTION: (Exception) Query "joined" is unknown to application search engine "PhabricatorProjectSearchEngine"! at [/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php:80] ``` Closes T15792 Test Plan: While logged in, set up a dashboard query panel with "Search For: Maniphest Tasks" and "Query: Assigned" and add it to a public Dashboard. While logged out, access the Dashboard and see explanation message instead of `Exception: Query "assigned" is unknown to application search engine "ManiphestTaskSearchEngine"!` on the dashboard. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15792 Differential Revision: https://we.phorge.it/D25598 --- src/__phutil_library_map__.php | 2 ++ .../paneltype/PhabricatorDashboardQueryPanelType.php | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 17b1e837a6..08fedabd49 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1798,6 +1798,7 @@ phutil_register_library_map(array( 'ManiphestCustomFieldStringIndex' => 'applications/maniphest/storage/ManiphestCustomFieldStringIndex.php', 'ManiphestDAO' => 'applications/maniphest/storage/ManiphestDAO.php', 'ManiphestDefaultEditCapability' => 'applications/maniphest/capability/ManiphestDefaultEditCapability.php', + 'ManiphestDefaultPriorityEditCapability' => 'applications/maniphest/capability/ManiphestDefaultPriorityEditCapability.php', 'ManiphestDefaultViewCapability' => 'applications/maniphest/capability/ManiphestDefaultViewCapability.php', 'ManiphestEditConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestEditConduitAPIMethod.php', 'ManiphestEditEngine' => 'applications/maniphest/editor/ManiphestEditEngine.php', @@ -8004,6 +8005,7 @@ phutil_register_library_map(array( 'ManiphestCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage', 'ManiphestDAO' => 'PhabricatorLiskDAO', 'ManiphestDefaultEditCapability' => 'PhabricatorPolicyCapability', + 'ManiphestDefaultPriorityEditCapability' => 'PhabricatorPolicyCapability', 'ManiphestDefaultViewCapability' => 'PhabricatorPolicyCapability', 'ManiphestEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 'ManiphestEditEngine' => 'PhabricatorEditEngine', diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php index c8cfe4fd2e..cd0843f3c2 100644 --- a/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php +++ b/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php @@ -77,6 +77,12 @@ final class PhabricatorDashboardQueryPanelType } if (!$saved) { + if (!$viewer->isLoggedIn()) { + // If user is not logged in, authored/assigned/etc queries are empty. + return id(new PHUIObjectItemListView()) + ->setUser($viewer) + ->setNoDataString(pht('You must log in to access this panel.')); + } throw new Exception( pht( 'Query "%s" is unknown to application search engine "%s"!',