1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +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:
epriestley 2014-07-17 18:37:09 -07:00
parent 48f6189f32
commit 17afcdcf95

View file

@ -57,33 +57,67 @@ final class PhabricatorSearchAttachController
$phids = array_values($phids);
if ($edge_type) {
if (!$object instanceof PhabricatorApplicationTransactionInterface) {
throw new Exception(
pht(
'Expected object ("%s") to implement interface "%s".',
get_class($object),
'PhabricatorApplicationTransactionInterface'));
if ($object instanceof PhabricatorRepositoryCommit) {
// TODO: Remove this entire branch of special cased grossness
// after T4896.
$old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$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());
} else {
return $this->performMerge($object, $handle, $phids);