mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-22 04:31:13 +01:00
Explicitly degrade edge editing for commit/task edges until T4896
Summary: Commits don't support `PhabricatorApplicationTransactionInterface` yet, so the "Edit Maniphest Tasks" dialog from the commit UI currently bombs. Hard-code it to do the correct writes in a low-level way. After T4896 we can remove this and do `ApplicationTransaction` stuff. Test Plan: Used the "Edit Maniphest Tasks" UI from Diffusion. Reviewers: joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D9975
This commit is contained in:
parent
48f6189f32
commit
17afcdcf95
1 changed files with 59 additions and 25 deletions
|
@ -57,33 +57,67 @@ final class PhabricatorSearchAttachController
|
||||||
$phids = array_values($phids);
|
$phids = array_values($phids);
|
||||||
|
|
||||||
if ($edge_type) {
|
if ($edge_type) {
|
||||||
if (!$object instanceof PhabricatorApplicationTransactionInterface) {
|
if ($object instanceof PhabricatorRepositoryCommit) {
|
||||||
throw new Exception(
|
// TODO: Remove this entire branch of special cased grossness
|
||||||
pht(
|
// after T4896.
|
||||||
'Expected object ("%s") to implement interface "%s".',
|
|
||||||
get_class($object),
|
$old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||||
'PhabricatorApplicationTransactionInterface'));
|
$this->phid,
|
||||||
|
$edge_type);
|
||||||
|
$add_phids = $phids;
|
||||||
|
$rem_phids = array_diff($old_phids, $add_phids);
|
||||||
|
|
||||||
|
// Doing this correctly (in a way that writes edge transactions) would
|
||||||
|
// be a huge mess and we don't get the commit half of the transaction
|
||||||
|
// anyway until T4896, so just write the edges themselves and skip
|
||||||
|
// the transactions for now.
|
||||||
|
|
||||||
|
$editor = new PhabricatorEdgeEditor();
|
||||||
|
foreach ($add_phids as $phid) {
|
||||||
|
$editor->addEdge(
|
||||||
|
$object->getPHID(),
|
||||||
|
DiffusionCommitHasTaskEdgeType::EDGECONST,
|
||||||
|
$phid);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($rem_phids as $phid) {
|
||||||
|
$editor->removeEdge(
|
||||||
|
$object->getPHID(),
|
||||||
|
DiffusionCommitHasTaskEdgeType::EDGECONST,
|
||||||
|
$phid);
|
||||||
|
}
|
||||||
|
|
||||||
|
$editor->save();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (!$object instanceof PhabricatorApplicationTransactionInterface) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Expected object ("%s") to implement interface "%s".',
|
||||||
|
get_class($object),
|
||||||
|
'PhabricatorApplicationTransactionInterface'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||||
|
$this->phid,
|
||||||
|
$edge_type);
|
||||||
|
$add_phids = $phids;
|
||||||
|
$rem_phids = array_diff($old_phids, $add_phids);
|
||||||
|
|
||||||
|
$txn_editor = $object->getApplicationTransactionEditor()
|
||||||
|
->setActor($user)
|
||||||
|
->setContentSourceFromRequest($request);
|
||||||
|
$txn_template = $object->getApplicationTransactionTemplate()
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $edge_type)
|
||||||
|
->setNewValue(array(
|
||||||
|
'+' => array_fuse($add_phids),
|
||||||
|
'-' => array_fuse($rem_phids)));
|
||||||
|
$txn_editor->applyTransactions(
|
||||||
|
$object->getApplicationTransactionObject(),
|
||||||
|
array($txn_template));
|
||||||
}
|
}
|
||||||
|
|
||||||
$old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
||||||
$this->phid,
|
|
||||||
$edge_type);
|
|
||||||
$add_phids = $phids;
|
|
||||||
$rem_phids = array_diff($old_phids, $add_phids);
|
|
||||||
|
|
||||||
$txn_editor = $object->getApplicationTransactionEditor()
|
|
||||||
->setActor($user)
|
|
||||||
->setContentSourceFromRequest($request);
|
|
||||||
$txn_template = $object->getApplicationTransactionTemplate()
|
|
||||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
|
||||||
->setMetadataValue('edge:type', $edge_type)
|
|
||||||
->setNewValue(array(
|
|
||||||
'+' => array_fuse($add_phids),
|
|
||||||
'-' => array_fuse($rem_phids)));
|
|
||||||
$txn_editor->applyTransactions(
|
|
||||||
$object->getApplicationTransactionObject(),
|
|
||||||
array($txn_template));
|
|
||||||
|
|
||||||
return id(new AphrontReloadResponse())->setURI($handle->getURI());
|
return id(new AphrontReloadResponse())->setURI($handle->getURI());
|
||||||
} else {
|
} else {
|
||||||
return $this->performMerge($object, $handle, $phids);
|
return $this->performMerge($object, $handle, $phids);
|
||||||
|
|
Loading…
Reference in a new issue