1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Work around exception in Herald transcript of old tasks: Call to a member function getAppliedTransactionPHIDs() on bool

Summary:
In some cases, older Herald transcripts which got garbage collected display an exception.
For unknown reasons, calling `getObjectTranscript()` on the HeraldTranscript object `$xscript` can return a bool with the value `false`.
Afterwards, calling `getAppliedTransactionPHIDs()` on that bool throws an exception.
Thus as a workaround, return an empty array instead in this case, like the code already does when $xscript->getObjectTranscript()->getAppliedTransactionPHIDs() === null.

Note that it remains unclear whether/when the bool may have the value `true` hence this situation is not covered by this code change (the code would still throw an exception in this situation).

Closes T15343

Test Plan:
1. Change system time to one year back (or optionally, use `./phorge/bin/garbage set-policy --collector herald.transcripts --days 1`, drop steps 9 and 10, and wait a day before performing step 11)
2. As an admin, go to http://phorge.localhost/herald/create/
3. Select "Maniphest Tasks"
4. On http://phorge.localhost/herald/create/?adapter=HeraldManiphestTaskAdapter , select "Global Rule"
5. Under "Conditions", select `any of` and set the three conditions `Description | contains | Internet Archive`, `Description | contains | archive.org`, `Description | contains | Wayback Machine`.
6. Under "Action", select `Add projects | someProject`
7. Select "Save Rule"
8. Trigger the rule by creating a new task.
9. Change system time back to today
10. On the shell, run `./phorge/bin/phd restart`
11. Visit created task and select "View Herald Transcript"
12. Transcript page displays "Old Transcript - Details of this transcript have been garbage collected." and shows no exception anymore

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15343

Differential Revision: https://we.phorge.it/D25246
This commit is contained in:
Andre Klapper 2023-06-12 21:48:20 +02:00
parent 3f8846d80c
commit 54ee51d7ab

View file

@ -717,8 +717,8 @@ final class HeraldTranscriptController extends HeraldController {
->setName(pht('Field Values')) ->setName(pht('Field Values'))
->setIcon('fa-file-text-o'); ->setIcon('fa-file-text-o');
$xaction_phids = $this->getTranscriptTransactionPHIDs($xscript); $has_xactions = $xscript->getObjectTranscript()
$has_xactions = (bool)$xaction_phids; && $this->getTranscriptTransactionPHIDs($xscript);
$nav->newLink('xactions') $nav->newLink('xactions')
->setName(pht('Transactions')) ->setName(pht('Transactions'))