Show login page if a search token requires a valid viewer
Summary:
A saved query can have tokens that require a valid current viewer. For example, this token:
viewer()
Before this change, visiting such saved queries would cause this:
This datasource ("PhabricatorPeopleUserFunctionDatasource") can not evaluate the function "viewer(...)".
After this change, instead of that, you are just redirected to the login page,
so, after you do the login, you are redirected back to that saved query and it works.
This fix was boosted during the Wikimedia Hackaton (wmhack) in Tallinn. Thanks Tallinn!
https://phabricator.wikimedia.org/T356384
Fixes T15704
Test Plan:
Go to Maniphest > Advanced Search > Assigned to > "Viewer". It still works.
Visit the same page in a new anonymous tab: now it redirects to the login page. You login,
and that page works again.
Do the same specific test for all these cases:
- Maniphest
- Assigned To: viewer
- Tags: current Viewer's Projects
- Authors: viewer
- Subscribers: ...
- Closed by
- Badges
- Subscribers
- Differential
- Responsible Users
- Authors
- Reviewers
- Subscribers
- Tags
- Dashboards
- Authored By
- Tags
- Dashboard Panels
- Authored By
- Dashboard Portals
- Tags
- Calendar:
- Hosts
- Invited
- Subscribers
- Tags
- Countdown
- Authors
- Diffusion
- Tags
- Subscribers
- Tags
- Diffusion commit
- Responsible Users
- Authors
- Subscribers
- Tags
- Diffusion identities
- Matching Users
- Feed
- Include Users
- Include Projects (interestingly it does not support "current Viewer's Projects")
- Files
- Authors
- Herald
- Authors
- Subscribers
- Legalpad
- Subscribers
- Nuance (none of their entity support search by token)
- Passphrase
- Subscribers
- Paste
- Authors
- Subscribers
- Tags
- Phame
- Subscribers
- Tags
- Pholio
- Authors
- Subscribers
- Tags
- Phrequent
- Users (interestingly it does not support "viewer")
- Ponder
- Authors
- Answered By
- Projects
- Members
- Watchers
- Transactions - /feed/transactions/
- Authors
- General search at /search/query/
- Authors
- Owners
- Subscribers
- Tags
All the above fields were tested in a clean search, one at a time, both logged-in and logged-out, with the function "viewer" or anything similar like "current Viewer's Projects":
For all cases, the login page appeared successfully where needed, instead of a crash.
Reviewers: O1 Blessed Committers, aklapper
Reviewed By: O1 Blessed Committers, aklapper
Subscribers: aklapper, avivey, tobiaswiese, Matthew, Cigaryno
Maniphest Tasks: T15704
Differential Revision: https://we.phorge.it/D25621