1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

In the Herald test console, don't consider transactions that Herald rules applied

Summary:
Depends on D20546. Ref T13283. Currently, if you do something (transactions "A", "B") and Herald does some things in response (transaction "C"), Herald acts only on the things you did ("A", "B") since the thing it did ("C") didn't exist yet, until it ran.

However, if you use the test console to test rules against the object we'll pick up all three transactions since they're all part of the same group. This isn't ideal.

To fix this, skip transactions which Herald applied, since it obviously didn't consider them when it was evaluating.

Test Plan:
  - Created a revision, in the presence of a Herald rule that adds reviewers.
  - Then, ran the revision through the test console.
  - Before: saw the "Herald added reviewers: ..." transaction in the transaction group Herald evaluated.
  - After: saw only authentic human transactions.

{F6464064}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13283

Differential Revision: https://secure.phabricator.com/D20547
This commit is contained in:
epriestley 2019-05-22 14:44:49 -07:00
parent 31e623afcc
commit 2e2dc47f07

View file

@ -271,6 +271,16 @@ final class HeraldTestConsoleController extends HeraldController {
$recent_id = null;
$hard_limit = 1000;
foreach ($xactions as $xaction) {
// If this transaction has Herald transcript metadata, it was applied by
// Herald. Exclude it from the list because the Herald rule engine always
// runs before Herald transactions apply, so there's no way that real
// rules would have seen this transaction.
$transcript_id = $xaction->getMetadataValue('herald:transcriptID');
if ($transcript_id !== null) {
continue;
}
$group_id = $xaction->getTransactionGroupID();
// If this is the first transaction, save the group ID: we want to