mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-22 20:51:10 +01:00
Merge multiple Auditors transactions from Herald
Summary: Fixes T12302. Currently, we aren't merging multiple "AddAuditors" transactions correctly. This can occur when Herald triggers multiple auditor rules. Instead, merge them. Test Plan: - Wrote two different Herald rules that add auditors. - Pushed a commit which triggered them. - After the change, saw all the auditors get added correctly. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12302 Differential Revision: https://secure.phabricator.com/D17403
This commit is contained in:
parent
3eae9a368d
commit
3b6a651b69
3 changed files with 38 additions and 0 deletions
|
@ -58,6 +58,31 @@ final class DiffusionCommitAuditorsTransaction
|
|||
return ($old !== $new);
|
||||
}
|
||||
|
||||
public function mergeTransactions(
|
||||
$object,
|
||||
PhabricatorApplicationTransaction $u,
|
||||
PhabricatorApplicationTransaction $v) {
|
||||
|
||||
$u_new = $u->getNewValue();
|
||||
$v_new = $v->getNewValue();
|
||||
|
||||
$result = $v_new;
|
||||
foreach (array('-', '+') as $key) {
|
||||
$u_value = idx($u_new, $key, array());
|
||||
$v_value = idx($v_new, $key, array());
|
||||
|
||||
$merged = $u_value + $v_value;
|
||||
|
||||
if ($merged) {
|
||||
$result[$key] = $merged;
|
||||
}
|
||||
}
|
||||
|
||||
$u->setNewValue($result);
|
||||
|
||||
return $u;
|
||||
}
|
||||
|
||||
public function applyExternalEffects($object, $value) {
|
||||
$src_phid = $object->getPHID();
|
||||
|
||||
|
|
|
@ -1462,6 +1462,12 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
|
||||
$type = $u->getTransactionType();
|
||||
|
||||
$xtype = $this->getModularTransactionType($type);
|
||||
if ($xtype) {
|
||||
$object = $this->object;
|
||||
return $xtype->mergeTransactions($object, $u, $v);
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||
return $this->mergePHIDOrEdgeTransactions($u, $v);
|
||||
|
|
|
@ -87,6 +87,13 @@ abstract class PhabricatorModularTransactionType
|
|||
return array();
|
||||
}
|
||||
|
||||
public function mergeTransactions(
|
||||
$object,
|
||||
PhabricatorApplicationTransaction $u,
|
||||
PhabricatorApplicationTransaction $v) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final public function setStorage(
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
$this->storage = $xaction;
|
||||
|
|
Loading…
Reference in a new issue