1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-12 08:36:13 +01:00

Hovercards: Avoid "Undefined index: objectPHID" when passing bogus data

Summary:
Do not throw an exception when passing bogus parameters to hovercards but properly handle the missing array index by setting `$object_phid` to `null`.
In consequence, see a proper hovercard correctly displaying `Unknown Object (????)` instead of an exception.

Closes T15969

Test Plan:
* Go to http://phorge.localhost/search/hovercard/?cards={"whatever":{"whatever":"foobar"}} or http://phorge.localhost/?__path__=%2fsearch%2fhovercard%2f&cards={%22whatever%22:{%22whatever%22:%22foobar%22}} and see a nice `Unknown Object (????)` instead of an ugly exception
* Go to http://phorge.localhost/search/hovercard/?cards={%22PHID-TASK-12345678%2F%22%3A{%22objectPHID%22%3A%22PHID-TASK-12345678%22%2C%22contextPHID%22%3Anull}} (make sure to use a valid task PHID) and still see a correct hovercard rendered

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15969

Differential Revision: https://we.phorge.it/D25849
This commit is contained in:
Andre Klapper 2024-12-05 23:37:18 +01:00
parent e5d7c9aa4e
commit a5384ca604

View file

@ -98,7 +98,7 @@ final class PhabricatorSearchHovercardController
$results = array();
foreach ($cards as $card_key => $card) {
$object_phid = $card['objectPHID'];
$object_phid = idx($card, 'objectPHID');
$handle = $handles[$object_phid];
$object = idx($objects, $object_phid);