@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+1 -1
+1 -1
src/applications/search/controller/PhabricatorSearchHovercardController.php
··· 98 98 99 99 $results = array(); 100 100 foreach ($cards as $card_key => $card) { 101 - $object_phid = $card['objectPHID']; 101 + $object_phid = idx($card, 'objectPHID'); 102 102 103 103 $handle = $handles[$object_phid]; 104 104 $object = idx($objects, $object_phid);