mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Remove all edge events
Summary: Ref T5245. These were a bad idea. We no longer need actors for edge edits either, so remove those. Generally, edges have fit into the policy model as pure/low-level infrastructure, and they do not have any policy or capability information in and of themselves. Test Plan: `grep` Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9840
This commit is contained in:
parent
533e799c5f
commit
8cbfb49b4e
28 changed files with 19 additions and 125 deletions
|
@ -19,7 +19,6 @@ foreach ($revs as $rev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = new PhabricatorEdgeEditor();
|
$editor = new PhabricatorEdgeEditor();
|
||||||
$editor->setSuppressEvents(true);
|
|
||||||
foreach ($unsubscribed as $user_phid => $_) {
|
foreach ($unsubscribed as $user_phid => $_) {
|
||||||
$editor->addEdge(
|
$editor->addEdge(
|
||||||
$rev['phid'],
|
$rev['phid'],
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
echo "Migrating differential.revisionPHID to edges...\n";
|
echo "Migrating differential.revisionPHID to edges...\n";
|
||||||
$commit_table = new PhabricatorRepositoryCommit();
|
$commit_table = new PhabricatorRepositoryCommit();
|
||||||
$data_table = new PhabricatorRepositoryCommitData();
|
$data_table = new PhabricatorRepositoryCommitData();
|
||||||
$editor = id(new PhabricatorEdgeEditor())->setSuppressEvents(true);
|
$editor = new PhabricatorEdgeEditor();
|
||||||
$commit_table->establishConnection('w');
|
$commit_table->establishConnection('w');
|
||||||
$edges = 0;
|
$edges = 0;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ foreach (new LiskMigrationIterator($commit_table) as $commit) {
|
||||||
if ($edges % 256 == 0) {
|
if ($edges % 256 == 0) {
|
||||||
echo '.';
|
echo '.';
|
||||||
$editor->save();
|
$editor->save();
|
||||||
$editor = id(new PhabricatorEdgeEditor())->setSuppressEvents(true);
|
$editor = new PhabricatorEdgeEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,7 @@ foreach (new LiskMigrationIterator($table) as $revision) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = new PhabricatorEdgeEditor();
|
||||||
->setActor(PhabricatorUser::getOmnipotentUser());
|
|
||||||
|
|
||||||
foreach ($reviewer_phids as $dst) {
|
foreach ($reviewer_phids as $dst) {
|
||||||
if (phid_get_type($dst) == PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) {
|
if (phid_get_type($dst) == PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) {
|
||||||
// At least one old install ran into some issues here. Skip the row if we
|
// At least one old install ran into some issues here. Skip the row if we
|
||||||
|
|
|
@ -121,7 +121,6 @@ foreach ($map as $credential_type => $credential_usernames) {
|
||||||
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_USES_CREDENTIAL;
|
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_USES_CREDENTIAL;
|
||||||
|
|
||||||
id(new PhabricatorEdgeEditor())
|
id(new PhabricatorEdgeEditor())
|
||||||
->setActor($viewer)
|
|
||||||
->addEdge($repository->getPHID(), $edge_type, $credential->getPHID())
|
->addEdge($repository->getPHID(), $edge_type, $credential->getPHID())
|
||||||
->save();
|
->save();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ foreach (new LiskMigrationIterator($table) as $rev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = new PhabricatorEdgeEditor();
|
$editor = new PhabricatorEdgeEditor();
|
||||||
$editor->setSuppressEvents(true);
|
|
||||||
foreach ($deps as $dep) {
|
foreach ($deps as $dep) {
|
||||||
$editor->addEdge(
|
$editor->addEdge(
|
||||||
$rev->getPHID(),
|
$rev->getPHID(),
|
||||||
|
|
|
@ -15,7 +15,6 @@ foreach (new LiskMigrationIterator($table) as $task) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = new PhabricatorEdgeEditor();
|
$editor = new PhabricatorEdgeEditor();
|
||||||
$editor->setSuppressEvents(true);
|
|
||||||
foreach ($deps as $dep) {
|
foreach ($deps as $dep) {
|
||||||
$editor->addEdge(
|
$editor->addEdge(
|
||||||
$task->getPHID(),
|
$task->getPHID(),
|
||||||
|
|
|
@ -15,7 +15,6 @@ foreach (new LiskMigrationIterator($table) as $task) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = new PhabricatorEdgeEditor();
|
$editor = new PhabricatorEdgeEditor();
|
||||||
$editor->setSuppressEvents(true);
|
|
||||||
foreach ($revs as $rev) {
|
foreach ($revs as $rev) {
|
||||||
$editor->addEdge(
|
$editor->addEdge(
|
||||||
$task->getPHID(),
|
$task->getPHID(),
|
||||||
|
|
|
@ -22,7 +22,6 @@ foreach (new LiskMigrationIterator($table) as $proj) {
|
||||||
$members = ipull($members, 'userPHID');
|
$members = ipull($members, 'userPHID');
|
||||||
|
|
||||||
$editor = new PhabricatorEdgeEditor();
|
$editor = new PhabricatorEdgeEditor();
|
||||||
$editor->setSuppressEvents(true);
|
|
||||||
foreach ($members as $user_phid) {
|
foreach ($members as $user_phid) {
|
||||||
$editor->addEdge(
|
$editor->addEdge(
|
||||||
$proj->getPHID(),
|
$proj->getPHID(),
|
||||||
|
|
|
@ -4357,7 +4357,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorDraftDAO' => 'PhabricatorLiskDAO',
|
'PhabricatorDraftDAO' => 'PhabricatorLiskDAO',
|
||||||
'PhabricatorEdgeConfig' => 'PhabricatorEdgeConstants',
|
'PhabricatorEdgeConfig' => 'PhabricatorEdgeConstants',
|
||||||
'PhabricatorEdgeCycleException' => 'Exception',
|
'PhabricatorEdgeCycleException' => 'Exception',
|
||||||
'PhabricatorEdgeEditor' => 'PhabricatorEditor',
|
'PhabricatorEdgeEditor' => 'Phobject',
|
||||||
'PhabricatorEdgeGraph' => 'AbstractDirectedGraph',
|
'PhabricatorEdgeGraph' => 'AbstractDirectedGraph',
|
||||||
'PhabricatorEdgeQuery' => 'PhabricatorQuery',
|
'PhabricatorEdgeQuery' => 'PhabricatorQuery',
|
||||||
'PhabricatorEdgeTestCase' => 'PhabricatorTestCase',
|
'PhabricatorEdgeTestCase' => 'PhabricatorTestCase',
|
||||||
|
|
|
@ -216,8 +216,7 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case ConpherenceTransactionType::TYPE_FILES:
|
case ConpherenceTransactionType::TYPE_FILES:
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = new PhabricatorEdgeEditor();
|
||||||
->setActor($this->getActor());
|
|
||||||
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE;
|
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE;
|
||||||
$old = array_fill_keys($xaction->getOldValue(), true);
|
$old = array_fill_keys($xaction->getOldValue(), true);
|
||||||
$new = array_fill_keys($xaction->getNewValue(), true);
|
$new = array_fill_keys($xaction->getNewValue(), true);
|
||||||
|
|
|
@ -257,8 +257,7 @@ final class DifferentialJIRAIssuesField
|
||||||
$revision_phid,
|
$revision_phid,
|
||||||
$edge_type);
|
$edge_type);
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = new PhabricatorEdgeEditor();
|
||||||
->setActor($this->getViewer());
|
|
||||||
|
|
||||||
foreach (array_diff($edges, $edge_dsts) as $rem_edge) {
|
foreach (array_diff($edges, $edge_dsts) as $rem_edge) {
|
||||||
$editor->removeEdge($revision_phid, $edge_type, $rem_edge);
|
$editor->removeEdge($revision_phid, $edge_type, $rem_edge);
|
||||||
|
|
|
@ -34,8 +34,8 @@ final class DiffusionCommitEditController extends DiffusionController {
|
||||||
$new_proj_phids = array_values($proj_phids);
|
$new_proj_phids = array_values($proj_phids);
|
||||||
$rem_proj_phids = array_diff($current_proj_phids,
|
$rem_proj_phids = array_diff($current_proj_phids,
|
||||||
$new_proj_phids);
|
$new_proj_phids);
|
||||||
$editor = id(new PhabricatorEdgeEditor());
|
|
||||||
$editor->setActor($user);
|
$editor = id(new PhabricatorEdgeEditor());
|
||||||
foreach ($rem_proj_phids as $phid) {
|
foreach ($rem_proj_phids as $phid) {
|
||||||
$editor->removeEdge($commit_phid, $edge_type, $phid);
|
$editor->removeEdge($commit_phid, $edge_type, $phid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,6 @@ final class DoorkeeperFeedWorkerAsana extends DoorkeeperFeedWorker {
|
||||||
);
|
);
|
||||||
|
|
||||||
id(new PhabricatorEdgeEditor())
|
id(new PhabricatorEdgeEditor())
|
||||||
->setActor($viewer)
|
|
||||||
->addEdge($src_phid, $etype_main, $dst_phid, $edge_options)
|
->addEdge($src_phid, $etype_main, $dst_phid, $edge_options)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
@ -247,8 +246,7 @@ final class DoorkeeperFeedWorkerAsana extends DoorkeeperFeedWorker {
|
||||||
|
|
||||||
// Now, handle the subtasks.
|
// Now, handle the subtasks.
|
||||||
|
|
||||||
$sub_editor = id(new PhabricatorEdgeEditor())
|
$sub_editor = new PhabricatorEdgeEditor();
|
||||||
->setActor($viewer);
|
|
||||||
|
|
||||||
// First, find all the object references in Phabricator for tasks that we
|
// First, find all the object references in Phabricator for tasks that we
|
||||||
// know about and import their objects from Asana.
|
// know about and import their objects from Asana.
|
||||||
|
|
|
@ -859,8 +859,6 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
||||||
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE;
|
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE;
|
||||||
|
|
||||||
id(new PhabricatorEdgeEditor())
|
id(new PhabricatorEdgeEditor())
|
||||||
->setActor($actor)
|
|
||||||
->setSuppressEvents(true)
|
|
||||||
->addEdge($phid, $edge_type, $this->getPHID())
|
->addEdge($phid, $edge_type, $this->getPHID())
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,6 @@ final class LegalpadDocumentEditor
|
||||||
$type = PhabricatorEdgeConfig::TYPE_CONTRIBUTED_TO_OBJECT;
|
$type = PhabricatorEdgeConfig::TYPE_CONTRIBUTED_TO_OBJECT;
|
||||||
id(new PhabricatorEdgeEditor())
|
id(new PhabricatorEdgeEditor())
|
||||||
->addEdge($actor->getPHID(), $type, $object->getPHID())
|
->addEdge($actor->getPHID(), $type, $object->getPHID())
|
||||||
->setActor($actor)
|
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_CONTRIBUTOR;
|
$type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_CONTRIBUTOR;
|
||||||
|
|
|
@ -330,7 +330,6 @@ final class ManiphestTaskEditController extends ManiphestController {
|
||||||
|
|
||||||
if ($parent_task) {
|
if ($parent_task) {
|
||||||
id(new PhabricatorEdgeEditor())
|
id(new PhabricatorEdgeEditor())
|
||||||
->setActor($user)
|
|
||||||
->addEdge(
|
->addEdge(
|
||||||
$parent_task->getPHID(),
|
$parent_task->getPHID(),
|
||||||
PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK,
|
PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK,
|
||||||
|
|
|
@ -225,10 +225,7 @@ final class ManiphestTransactionEditor
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = new PhabricatorEdgeEditor();
|
||||||
->setActor($this->getActor())
|
|
||||||
->setSuppressEvents(true);
|
|
||||||
|
|
||||||
foreach ($add as $phid) {
|
foreach ($add as $phid) {
|
||||||
$editor->addEdge($src, $edge_type, $phid);
|
$editor->addEdge($src, $edge_type, $phid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ final class PonderVoteEditor extends PhabricatorEditor {
|
||||||
// prepare vote add, or update if this user is amending an
|
// prepare vote add, or update if this user is amending an
|
||||||
// earlier vote
|
// earlier vote
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = id(new PhabricatorEdgeEditor())
|
||||||
->setActor($actor)
|
|
||||||
->addEdge(
|
->addEdge(
|
||||||
$actor->getPHID(),
|
$actor->getPHID(),
|
||||||
$votable->getUserVoteEdgeType(),
|
$votable->getUserVoteEdgeType(),
|
||||||
|
|
|
@ -231,8 +231,7 @@ final class PhabricatorProjectTransactionEditor
|
||||||
|
|
||||||
if ($rem) {
|
if ($rem) {
|
||||||
// When removing members, also remove any watches on the project.
|
// When removing members, also remove any watches on the project.
|
||||||
$edge_editor = id(new PhabricatorEdgeEditor())
|
$edge_editor = new PhabricatorEdgeEditor();
|
||||||
->setSuppressEvents(true);
|
|
||||||
foreach ($rem as $rem_phid) {
|
foreach ($rem as $rem_phid) {
|
||||||
$edge_editor->removeEdge(
|
$edge_editor->removeEdge(
|
||||||
$object->getPHID(),
|
$object->getPHID(),
|
||||||
|
|
|
@ -225,8 +225,7 @@ final class PhabricatorRepositoryEditor
|
||||||
$old_phid = $xaction->getOldValue();
|
$old_phid = $xaction->getOldValue();
|
||||||
$new_phid = $xaction->getNewValue();
|
$new_phid = $xaction->getNewValue();
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = new PhabricatorEdgeEditor();
|
||||||
->setActor($this->requireActor());
|
|
||||||
|
|
||||||
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_USES_CREDENTIAL;
|
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_USES_CREDENTIAL;
|
||||||
$src_phid = $object->getPHID();
|
$src_phid = $object->getPHID();
|
||||||
|
|
|
@ -90,7 +90,6 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
if ($revision) {
|
if ($revision) {
|
||||||
$commit_drev = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV;
|
$commit_drev = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV;
|
||||||
id(new PhabricatorEdgeEditor())
|
id(new PhabricatorEdgeEditor())
|
||||||
->setActor($user)
|
|
||||||
->addEdge($commit->getPHID(), $commit_drev, $revision->getPHID())
|
->addEdge($commit->getPHID(), $commit_drev, $revision->getPHID())
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
@ -453,7 +452,6 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
// Maniphest edges is sorted out. Currently, Maniphest reacts to an edge
|
// Maniphest edges is sorted out. Currently, Maniphest reacts to an edge
|
||||||
// edit on this edge.
|
// edit on this edge.
|
||||||
id(new PhabricatorEdgeEditor())
|
id(new PhabricatorEdgeEditor())
|
||||||
->setActor($actor)
|
|
||||||
->addEdge(
|
->addEdge(
|
||||||
$task->getPHID(),
|
$task->getPHID(),
|
||||||
PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT,
|
PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT,
|
||||||
|
|
|
@ -83,8 +83,7 @@ final class PhabricatorSubscriptionsEditor extends PhabricatorEditor {
|
||||||
$u_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER;
|
$u_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER;
|
||||||
$s_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER;
|
$s_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER;
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = new PhabricatorEdgeEditor();
|
||||||
->setActor($actor);
|
|
||||||
|
|
||||||
foreach ($add as $phid => $ignored) {
|
foreach ($add as $phid => $ignored) {
|
||||||
$editor->removeEdge($src, $u_type, $phid);
|
$editor->removeEdge($src, $u_type, $phid);
|
||||||
|
|
|
@ -62,8 +62,7 @@ final class PhabricatorDestructionEngine extends Phobject {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = new PhabricatorEdgeEditor();
|
||||||
->setSuppressEvents(true);
|
|
||||||
foreach ($edges as $type => $type_edges) {
|
foreach ($edges as $type => $type_edges) {
|
||||||
foreach ($type_edges as $src => $src_edges) {
|
foreach ($type_edges as $src => $src_edges) {
|
||||||
foreach ($src_edges as $dst => $edge) {
|
foreach ($src_edges as $dst => $edge) {
|
||||||
|
|
|
@ -411,8 +411,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
$new[$dst_phid]['src'] = $src;
|
$new[$dst_phid]['src'] = $src;
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = new PhabricatorEdgeEditor();
|
||||||
->setActor($this->getActor());
|
|
||||||
|
|
||||||
foreach ($old as $dst_phid => $edge) {
|
foreach ($old as $dst_phid => $edge) {
|
||||||
if (!empty($new[$dst_phid])) {
|
if (!empty($new[$dst_phid])) {
|
||||||
|
@ -2346,11 +2345,6 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = id(new PhabricatorEdgeEditor())
|
||||||
->setActor($this->getActor());
|
->setActor($this->getActor());
|
||||||
|
|
||||||
// TODO: Edge-based events were almost certainly a terrible idea. If we
|
|
||||||
// don't suppress this event, the Maniphest listener reenters and adds
|
|
||||||
// more transactions. Just suppress it until that can get cleaned up.
|
|
||||||
$editor->setSuppressEvents(true);
|
|
||||||
|
|
||||||
$src = $object->getPHID();
|
$src = $object->getPHID();
|
||||||
$type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE;
|
$type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE;
|
||||||
foreach ($file_phids as $dst) {
|
foreach ($file_phids as $dst) {
|
||||||
|
|
|
@ -236,40 +236,6 @@ Data available on this event:
|
||||||
|
|
||||||
Using @{class@libphutil:PhutilEmailAddress} may be helpful in parsing the query.
|
Using @{class@libphutil:PhutilEmailAddress} may be helpful in parsing the query.
|
||||||
|
|
||||||
== Edge: Will Edit Edges ==
|
|
||||||
|
|
||||||
NOTE: Edge events are low-level events deep in the core. It is more difficult to
|
|
||||||
correct implement listeners for these events than for higher-level events.
|
|
||||||
|
|
||||||
The constant for this event is
|
|
||||||
`PhabricatorEventType::TYPE_EDGE_WILLEDITEDGES`.
|
|
||||||
|
|
||||||
This event is dispatched before @{class:PhabricatorEdgeEditor} makes an edge
|
|
||||||
edit.
|
|
||||||
|
|
||||||
- `id` An identifier for this edit operation.
|
|
||||||
- `add` A list of dictionaries, each representing a new edge.
|
|
||||||
- `rem` A list of dictionaries, each representing a removed edge.
|
|
||||||
|
|
||||||
This is similar to the next event (did edit edges) but occurs before the
|
|
||||||
edit begins.
|
|
||||||
|
|
||||||
== Edge: Did Edit Edges ==
|
|
||||||
|
|
||||||
The constant for this event is
|
|
||||||
`PhabricatorEventType::TYPE_EDGE_DIDEDITEDGES`.
|
|
||||||
|
|
||||||
This event is dispatched after @{class:PhabricatorEdgeEditor} makes an edge
|
|
||||||
edit, but before it commits the transactions. Data available on this event:
|
|
||||||
|
|
||||||
- `id` An identifier for this edit operation. This is the same ID as
|
|
||||||
the one included in the corresponding "will edit edges" event.
|
|
||||||
- `add` A list of dictionaries, each representing a new edge.
|
|
||||||
- `rem` A list of dictionaries, each representing a removed edge.
|
|
||||||
|
|
||||||
This is similar to the previous event (will edit edges) but occurs after the
|
|
||||||
edit completes.
|
|
||||||
|
|
||||||
== Search: Did Update Index ==
|
== Search: Did Update Index ==
|
||||||
|
|
||||||
The constant for this event is
|
The constant for this event is
|
||||||
|
|
|
@ -21,7 +21,6 @@ final class PhabricatorEdgeTestCase extends PhabricatorTestCase {
|
||||||
$phid2 = $obj2->getPHID();
|
$phid2 = $obj2->getPHID();
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = id(new PhabricatorEdgeEditor())
|
||||||
->setActor($user)
|
|
||||||
->addEdge($phid1, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid2)
|
->addEdge($phid1, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid2)
|
||||||
->addEdge($phid2, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid1);
|
->addEdge($phid2, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid1);
|
||||||
|
|
||||||
|
@ -39,12 +38,10 @@ final class PhabricatorEdgeTestCase extends PhabricatorTestCase {
|
||||||
// fail (it introduces a cycle).
|
// fail (it introduces a cycle).
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = id(new PhabricatorEdgeEditor())
|
||||||
->setActor($user)
|
|
||||||
->addEdge($phid1, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid2)
|
->addEdge($phid1, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid2)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$editor = id(new PhabricatorEdgeEditor())
|
$editor = id(new PhabricatorEdgeEditor())
|
||||||
->setActor($user)
|
|
||||||
->addEdge($phid2, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid1);
|
->addEdge($phid2, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid1);
|
||||||
|
|
||||||
$caught = null;
|
$caught = null;
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
* @{class:PhabricatorEdgeQuery} to load object edges. For more information
|
* @{class:PhabricatorEdgeQuery} to load object edges. For more information
|
||||||
* on edges, see @{article:Using Edges}.
|
* on edges, see @{article:Using Edges}.
|
||||||
*
|
*
|
||||||
|
* Edges are not directly policy aware, and this editor makes low-level changes
|
||||||
|
* below the policy layer.
|
||||||
|
*
|
||||||
* name=Adding Edges
|
* name=Adding Edges
|
||||||
* $src = $earth_phid;
|
* $src = $earth_phid;
|
||||||
* $type = PhabricatorEdgeConfig::TYPE_BODY_HAS_SATELLITE;
|
* $type = PhabricatorEdgeConfig::TYPE_BODY_HAS_SATELLITE;
|
||||||
|
@ -12,19 +15,17 @@
|
||||||
*
|
*
|
||||||
* id(new PhabricatorEdgeEditor())
|
* id(new PhabricatorEdgeEditor())
|
||||||
* ->addEdge($src, $type, $dst)
|
* ->addEdge($src, $type, $dst)
|
||||||
* ->setActor($user)
|
|
||||||
* ->save();
|
* ->save();
|
||||||
*
|
*
|
||||||
* @task edit Editing Edges
|
* @task edit Editing Edges
|
||||||
* @task cycles Cycle Prevention
|
* @task cycles Cycle Prevention
|
||||||
* @task internal Internals
|
* @task internal Internals
|
||||||
*/
|
*/
|
||||||
final class PhabricatorEdgeEditor extends PhabricatorEditor {
|
final class PhabricatorEdgeEditor extends Phobject {
|
||||||
|
|
||||||
private $addEdges = array();
|
private $addEdges = array();
|
||||||
private $remEdges = array();
|
private $remEdges = array();
|
||||||
private $openTransactions = array();
|
private $openTransactions = array();
|
||||||
private $suppressEvents;
|
|
||||||
|
|
||||||
|
|
||||||
/* -( Editing Edges )------------------------------------------------------ */
|
/* -( Editing Edges )------------------------------------------------------ */
|
||||||
|
@ -118,8 +119,6 @@ final class PhabricatorEdgeEditor extends PhabricatorEditor {
|
||||||
static $id = 0;
|
static $id = 0;
|
||||||
$id++;
|
$id++;
|
||||||
|
|
||||||
$this->sendEvent($id, PhabricatorEventType::TYPE_EDGE_WILLEDITEDGES);
|
|
||||||
|
|
||||||
// NOTE: Removes first, then adds, so that "remove + add" is a useful
|
// NOTE: Removes first, then adds, so that "remove + add" is a useful
|
||||||
// operation meaning "overwrite".
|
// operation meaning "overwrite".
|
||||||
|
|
||||||
|
@ -130,8 +129,6 @@ final class PhabricatorEdgeEditor extends PhabricatorEditor {
|
||||||
$this->detectCycles($src_phids, $cycle_type);
|
$this->detectCycles($src_phids, $cycle_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sendEvent($id, PhabricatorEventType::TYPE_EDGE_DIDEDITEDGES);
|
|
||||||
|
|
||||||
$this->saveTransactions();
|
$this->saveTransactions();
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
$caught = $ex;
|
$caught = $ex;
|
||||||
|
@ -351,37 +348,6 @@ final class PhabricatorEdgeEditor extends PhabricatorEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Suppress edge edit events. This prevents listeners from making updates in
|
|
||||||
* response to edits, and is primarily useful when performing migrations. You
|
|
||||||
* should not normally need to use it.
|
|
||||||
*
|
|
||||||
* @param bool True to suppress events related to edits.
|
|
||||||
* @return this
|
|
||||||
* @task internal
|
|
||||||
*/
|
|
||||||
public function setSuppressEvents($suppress) {
|
|
||||||
$this->suppressEvents = $suppress;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function sendEvent($edit_id, $event_type) {
|
|
||||||
if ($this->suppressEvents) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$event = new PhabricatorEvent(
|
|
||||||
$event_type,
|
|
||||||
array(
|
|
||||||
'id' => $edit_id,
|
|
||||||
'add' => $this->addEdges,
|
|
||||||
'rem' => $this->remEdges,
|
|
||||||
));
|
|
||||||
$event->setUser($this->getActor());
|
|
||||||
PhutilEventEngine::dispatchEvent($event);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* -( Cycle Prevention )--------------------------------------------------- */
|
/* -( Cycle Prevention )--------------------------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,6 @@ final class PhabricatorEventType extends PhutilEventType {
|
||||||
const TYPE_DIFFUSION_DIDDISCOVERCOMMIT = 'diffusion.didDiscoverCommit';
|
const TYPE_DIFFUSION_DIDDISCOVERCOMMIT = 'diffusion.didDiscoverCommit';
|
||||||
const TYPE_DIFFUSION_LOOKUPUSER = 'diffusion.lookupUser';
|
const TYPE_DIFFUSION_LOOKUPUSER = 'diffusion.lookupUser';
|
||||||
|
|
||||||
const TYPE_EDGE_WILLEDITEDGES = 'edge.willEditEdges';
|
|
||||||
const TYPE_EDGE_DIDEDITEDGES = 'edge.didEditEdges';
|
|
||||||
|
|
||||||
const TYPE_TEST_DIDRUNTEST = 'test.didRunTest';
|
const TYPE_TEST_DIDRUNTEST = 'test.didRunTest';
|
||||||
|
|
||||||
const TYPE_UI_DIDRENDERACTIONS = 'ui.didRenderActions';
|
const TYPE_UI_DIDRENDERACTIONS = 'ui.didRenderActions';
|
||||||
|
|
Loading…
Reference in a new issue