@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+58 -24
+58 -24
src/applications/search/controller/PhabricatorSearchAttachController.php
··· 57 57 $phids = array_values($phids); 58 58 59 59 if ($edge_type) { 60 - if (!$object instanceof PhabricatorApplicationTransactionInterface) { 61 - throw new Exception( 62 - pht( 63 - 'Expected object ("%s") to implement interface "%s".', 64 - get_class($object), 65 - 'PhabricatorApplicationTransactionInterface')); 66 - } 60 + if ($object instanceof PhabricatorRepositoryCommit) { 61 + // TODO: Remove this entire branch of special cased grossness 62 + // after T4896. 63 + 64 + $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( 65 + $this->phid, 66 + $edge_type); 67 + $add_phids = $phids; 68 + $rem_phids = array_diff($old_phids, $add_phids); 67 69 68 - $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( 69 - $this->phid, 70 - $edge_type); 71 - $add_phids = $phids; 72 - $rem_phids = array_diff($old_phids, $add_phids); 70 + // Doing this correctly (in a way that writes edge transactions) would 71 + // be a huge mess and we don't get the commit half of the transaction 72 + // anyway until T4896, so just write the edges themselves and skip 73 + // the transactions for now. 73 74 74 - $txn_editor = $object->getApplicationTransactionEditor() 75 - ->setActor($user) 76 - ->setContentSourceFromRequest($request); 77 - $txn_template = $object->getApplicationTransactionTemplate() 78 - ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 79 - ->setMetadataValue('edge:type', $edge_type) 80 - ->setNewValue(array( 81 - '+' => array_fuse($add_phids), 82 - '-' => array_fuse($rem_phids))); 83 - $txn_editor->applyTransactions( 84 - $object->getApplicationTransactionObject(), 85 - array($txn_template)); 75 + $editor = new PhabricatorEdgeEditor(); 76 + foreach ($add_phids as $phid) { 77 + $editor->addEdge( 78 + $object->getPHID(), 79 + DiffusionCommitHasTaskEdgeType::EDGECONST, 80 + $phid); 81 + } 82 + 83 + foreach ($rem_phids as $phid) { 84 + $editor->removeEdge( 85 + $object->getPHID(), 86 + DiffusionCommitHasTaskEdgeType::EDGECONST, 87 + $phid); 88 + } 89 + 90 + $editor->save(); 91 + 92 + } else { 93 + if (!$object instanceof PhabricatorApplicationTransactionInterface) { 94 + throw new Exception( 95 + pht( 96 + 'Expected object ("%s") to implement interface "%s".', 97 + get_class($object), 98 + 'PhabricatorApplicationTransactionInterface')); 99 + } 100 + 101 + $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( 102 + $this->phid, 103 + $edge_type); 104 + $add_phids = $phids; 105 + $rem_phids = array_diff($old_phids, $add_phids); 106 + 107 + $txn_editor = $object->getApplicationTransactionEditor() 108 + ->setActor($user) 109 + ->setContentSourceFromRequest($request); 110 + $txn_template = $object->getApplicationTransactionTemplate() 111 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 112 + ->setMetadataValue('edge:type', $edge_type) 113 + ->setNewValue(array( 114 + '+' => array_fuse($add_phids), 115 + '-' => array_fuse($rem_phids))); 116 + $txn_editor->applyTransactions( 117 + $object->getApplicationTransactionObject(), 118 + array($txn_template)); 119 + } 86 120 87 121 return id(new AphrontReloadResponse())->setURI($handle->getURI()); 88 122 } else {