From 95662ae8f1a76eca66b024a11a21f5c5e8a7e01e Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 7 Apr 2021 14:49:03 -0700 Subject: [PATCH] Don't attempt to test capabilities on incomplete handles Summary: As backstory: I accidentally added the subscriber `PHID-USER-abcd` to `T1` on this install by calling `maniphest.edit`. I intended to edit `T1` on my local install. This edit is permitted for messy technical reasons, described in T13429. It's not valid, but it's hard to prevent. The state we reach is also possible even if the edit is rejected (i.e., someone can go manually update the database). Regardless of how we get into this state, the state (a non-user subscriber) breaks the UI on the task page when it attempts to test if the subscriber can see the task. To prevent this, only claim that a Handle can have capabilities if the handle is complete. If the handle is incomplete (an invalid or restricted object), it either can't be meaningfully tested for capabilities or the viewer isn't allowed to know them. Test Plan: Viewed `T1` on this install, saw a fatal. Applied the same edit to `T1` locally, got the same fatal. Applied patch, no more fatal. Now saw "Unknown Object (User)" in subscriber curtain. Specifically, the fatal is: > Attempting to test capability "view" for handle of type "USER", but this capability has not been attached. Differential Revision: https://secure.phabricator.com/D21662 --- src/applications/phid/PhabricatorObjectHandle.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php index 95c40ffa2b..577fd05692 100644 --- a/src/applications/phid/PhabricatorObjectHandle.php +++ b/src/applications/phid/PhabricatorObjectHandle.php @@ -402,6 +402,10 @@ final class PhabricatorObjectHandle } public function hasCapabilities() { + if (!$this->isComplete()) { + return false; + } + return ($this->getType() === PhabricatorPeopleUserPHIDType::TYPECONST); }