From a68b8daafde3824319727b3ef40b8e081434dc9a Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Wed, 19 Jun 2024 22:32:57 +0200 Subject: [PATCH] Avoid "Unknown Object (????)" for custom Select field values in Herald editor Summary: Custom Select field values are rendered as `Unknown Object (????)` when set as Herald rule conditions and editing the Herald rule. This is unhelpful; at least display their key value. Closes T15860 Test Plan: Create a `"type": "select"` custom field via `/config/edit/maniphest.custom-field-definitions/`, set up a Herald rule with a condition based on that custom field, edit the Herald rule. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15860 Differential Revision: https://we.phorge.it/D25696 --- src/applications/phid/PhabricatorObjectHandle.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php index b42dfdf863..deac8e63d6 100644 --- a/src/applications/phid/PhabricatorObjectHandle.php +++ b/src/applications/phid/PhabricatorObjectHandle.php @@ -168,6 +168,19 @@ final class PhabricatorObjectHandle if ($this->name === null) { if ($this->getPolicyFiltered()) { return pht('Restricted %s', $this->getTypeName()); + } else if ($this->getPHID() && $this->getTypeName() === + PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) { + // Values of custom Select field conditions in Herald rules do not have + // a PHID (and no PHID type) as they are arbitrary text when loadPage() + // in PhabricatorHandleQuery calls $type = phid_get_type($phid). + // Thus the code lower in this class cannot pull a name to render for + // these non-existing PHIDs either. + // In this case, render their PHID (the actual Select field key value). + // This is always more informative than 'Unknown Object (????)' though + // still imperfect as it displays the key instead of the user-friendly + // name value defined in maniphest.custom-field-definitions. + // https://we.phorge.it/T15860 + return $this->getPHID(); } else { return pht('Unknown Object (%s)', $this->getTypeName()); }