Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15546324
D10138.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D10138.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4851,6 +4851,7 @@
'PhabricatorSubscribableInterface',
'HarbormasterBuildableInterface',
'PhabricatorCustomFieldInterface',
+ 'PhabricatorApplicationTransactionInterface',
),
'PhabricatorRepositoryCommitChangeParserWorker' => 'PhabricatorRepositoryCommitParserWorker',
'PhabricatorRepositoryCommitData' => 'PhabricatorRepositoryDAO',
diff --git a/src/applications/audit/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php
--- a/src/applications/audit/editor/PhabricatorAuditEditor.php
+++ b/src/applications/audit/editor/PhabricatorAuditEditor.php
@@ -7,6 +7,7 @@
$types = parent::getTransactionTypes();
$types[] = PhabricatorTransactions::TYPE_COMMENT;
+ $types[] = PhabricatorTransactions::TYPE_EDGE;
// TODO: These will get modernized eventually, but that can happen one
// at a time later on.
@@ -66,6 +67,7 @@
switch ($xaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
+ case PhabricatorTransactions::TYPE_EDGE:
case PhabricatorAuditActionConstants::ACTION:
case PhabricatorAuditActionConstants::INLINE:
case PhabricatorAuditActionConstants::ADD_AUDITORS:
@@ -82,6 +84,7 @@
switch ($xaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
+ case PhabricatorTransactions::TYPE_EDGE:
case PhabricatorAuditActionConstants::ACTION:
case PhabricatorAuditActionConstants::INLINE:
return;
@@ -130,6 +133,20 @@
PhabricatorLiskDAO $object,
array $xactions) {
+ // Load auditors explicitly; we may not have them if the caller was a
+ // generic piece of infrastructure.
+
+ $commit = id(new DiffusionCommitQuery())
+ ->setViewer($this->requireActor())
+ ->withIDs(array($object->getID()))
+ ->needAuditRequests(true)
+ ->executeOne();
+ if (!$commit) {
+ throw new Exception(
+ pht('Failed to load commit during transaction finalization!'));
+ }
+ $object->attachAudits($commit->getAudits());
+
$status_concerned = PhabricatorAuditStatusConstants::CONCERNED;
$status_closed = PhabricatorAuditStatusConstants::CLOSED;
$status_resigned = PhabricatorAuditStatusConstants::RESIGNED;
diff --git a/src/applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php b/src/applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php
--- a/src/applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php
+++ b/src/applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php
@@ -5,9 +5,11 @@
const EDGECONST = 2;
public function shouldWriteInverseTransactions() {
- // TODO: This should happen after T4896, but Diffusion does not support
- // transactions yet.
- return false;
+ return true;
+ }
+
+ public function getInverseEdgeConstant() {
+ return ManiphestTaskHasCommitEdgeType::EDGECONST;
}
public function getTransactionAddString(
diff --git a/src/applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php b/src/applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php
--- a/src/applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php
+++ b/src/applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php
@@ -5,9 +5,11 @@
const EDGECONST = 1;
public function shouldWriteInverseTransactions() {
- // TODO: This should happen after T4896, but Diffusion does not support
- // transactions yet.
- return false;
+ return true;
+ }
+
+ public function getInverseEdgeConstant() {
+ return DiffusionCommitHasTaskEdgeType::EDGECONST;
}
public function getTransactionAddString(
diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
--- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
@@ -8,7 +8,8 @@
PhabricatorTokenReceiverInterface,
PhabricatorSubscribableInterface,
HarbormasterBuildableInterface,
- PhabricatorCustomFieldInterface {
+ PhabricatorCustomFieldInterface,
+ PhabricatorApplicationTransactionInterface {
protected $repositoryID;
protected $phid;
@@ -351,4 +352,20 @@
return true;
}
+
+/* -( PhabricatorApplicationTransactionInterface )------------------------- */
+
+
+ public function getApplicationTransactionEditor() {
+ return new PhabricatorAuditEditor();
+ }
+
+ public function getApplicationTransactionObject() {
+ return $this;
+ }
+
+ public function getApplicationTransactionTemplate() {
+ return new PhabricatorAuditTransaction();
+ }
+
}
diff --git a/src/applications/search/controller/PhabricatorSearchAttachController.php b/src/applications/search/controller/PhabricatorSearchAttachController.php
--- a/src/applications/search/controller/PhabricatorSearchAttachController.php
+++ b/src/applications/search/controller/PhabricatorSearchAttachController.php
@@ -57,69 +57,35 @@
$phids = array_values($phids);
if ($edge_type) {
- 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)
- ->setContinueOnMissingFields(true);
-
- $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));
+ 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)
+ ->setContinueOnMissingFields(true);
+
+ $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);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 27, 3:01 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7354650
Default Alt Text
D10138.diff (8 KB)
Attached To
Mode
D10138: Use standard infrastructure to attach commits to other objects
Attached
Detach File
Event Timeline
Log In to Comment