1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

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 [<phorge>/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php:80]
EXCEPTION: (Exception) Query "joined" is unknown to application search engine "PhabricatorProjectSearchEngine"! at [<phorge>/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
This commit is contained in:
Andre Klapper 2024-04-19 13:51:52 +02:00
parent 4d12d014fd
commit b32b84b645
2 changed files with 8 additions and 0 deletions

View file

@ -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',

View file

@ -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"!',