mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-11 20:04:53 +01:00
Transactions - fix inverse edge transaction writes
Summary: Ref XXXXX. I broke things a bit in XXXXX in that if the TYPE_EDGE had an inverse transaction, we weren't correctly "doing nothing" and instead were falling back to our old every editor has to implement a no-op ways... Fix things by putting the TYPE_EDGE code in the handle external builtin function like it belongs. Test Plan: made a comment on a task referencng a commit successfully Reviewers: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6403 Differential Revision: https://secure.phabricator.com/D12939
This commit is contained in:
parent
b5bf8e998d
commit
f05a7ed7b5
1 changed files with 56 additions and 53 deletions
|
@ -438,61 +438,10 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
$this->subscribers = $subscribers;
|
$this->subscribers = $subscribers;
|
||||||
return $this->applyBuiltinExternalTransaction($object, $xaction);
|
return $this->applyBuiltinExternalTransaction($object, $xaction);
|
||||||
|
|
||||||
case PhabricatorTransactions::TYPE_EDGE:
|
|
||||||
if ($this->getIsInverseEdgeEditor()) {
|
|
||||||
// If we're writing an inverse edge transaction, don't actually
|
|
||||||
// do anything. The initiating editor on the other side of the
|
|
||||||
// transaction will take care of the edge writes.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$old = $xaction->getOldValue();
|
|
||||||
$new = $xaction->getNewValue();
|
|
||||||
$src = $object->getPHID();
|
|
||||||
$const = $xaction->getMetadataValue('edge:type');
|
|
||||||
|
|
||||||
$type = PhabricatorEdgeType::getByConstant($const);
|
|
||||||
if ($type->shouldWriteInverseTransactions()) {
|
|
||||||
$this->applyInverseEdgeTransactions(
|
|
||||||
$object,
|
|
||||||
$xaction,
|
|
||||||
$type->getInverseEdgeConstant());
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($new as $dst_phid => $edge) {
|
|
||||||
$new[$dst_phid]['src'] = $src;
|
|
||||||
}
|
|
||||||
|
|
||||||
$editor = new PhabricatorEdgeEditor();
|
|
||||||
|
|
||||||
foreach ($old as $dst_phid => $edge) {
|
|
||||||
if (!empty($new[$dst_phid])) {
|
|
||||||
if ($old[$dst_phid]['data'] === $new[$dst_phid]['data']) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$editor->removeEdge($src, $const, $dst_phid);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($new as $dst_phid => $edge) {
|
|
||||||
if (!empty($old[$dst_phid])) {
|
|
||||||
if ($old[$dst_phid]['data'] === $new[$dst_phid]['data']) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array(
|
|
||||||
'data' => $edge['data'],
|
|
||||||
);
|
|
||||||
|
|
||||||
$editor->addEdge($src, $const, $dst_phid, $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
$editor->save();
|
|
||||||
return $this->applyBuiltinExternalTransaction($object, $xaction);
|
|
||||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
||||||
$field = $this->getCustomFieldForTransaction($object, $xaction);
|
$field = $this->getCustomFieldForTransaction($object, $xaction);
|
||||||
return $field->applyApplicationTransactionExternalEffects($xaction);
|
return $field->applyApplicationTransactionExternalEffects($xaction);
|
||||||
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
|
@ -547,7 +496,61 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
protected function applyBuiltinExternalTransaction(
|
protected function applyBuiltinExternalTransaction(
|
||||||
PhabricatorLiskDAO $object,
|
PhabricatorLiskDAO $object,
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
return;
|
|
||||||
|
switch ($xaction->getTransactionType()) {
|
||||||
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
|
if ($this->getIsInverseEdgeEditor()) {
|
||||||
|
// If we're writing an inverse edge transaction, don't actually
|
||||||
|
// do anything. The initiating editor on the other side of the
|
||||||
|
// transaction will take care of the edge writes.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$old = $xaction->getOldValue();
|
||||||
|
$new = $xaction->getNewValue();
|
||||||
|
$src = $object->getPHID();
|
||||||
|
$const = $xaction->getMetadataValue('edge:type');
|
||||||
|
|
||||||
|
$type = PhabricatorEdgeType::getByConstant($const);
|
||||||
|
if ($type->shouldWriteInverseTransactions()) {
|
||||||
|
$this->applyInverseEdgeTransactions(
|
||||||
|
$object,
|
||||||
|
$xaction,
|
||||||
|
$type->getInverseEdgeConstant());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($new as $dst_phid => $edge) {
|
||||||
|
$new[$dst_phid]['src'] = $src;
|
||||||
|
}
|
||||||
|
|
||||||
|
$editor = new PhabricatorEdgeEditor();
|
||||||
|
|
||||||
|
foreach ($old as $dst_phid => $edge) {
|
||||||
|
if (!empty($new[$dst_phid])) {
|
||||||
|
if ($old[$dst_phid]['data'] === $new[$dst_phid]['data']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$editor->removeEdge($src, $const, $dst_phid);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($new as $dst_phid => $edge) {
|
||||||
|
if (!empty($old[$dst_phid])) {
|
||||||
|
if ($old[$dst_phid]['data'] === $new[$dst_phid]['data']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'data' => $edge['data'],
|
||||||
|
);
|
||||||
|
|
||||||
|
$editor->addEdge($src, $const, $dst_phid, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
$editor->save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue