@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.

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

+19 -125
-1
resources/sql/patches/20130201.revisionunsubscribed.php
··· 19 19 } 20 20 21 21 $editor = new PhabricatorEdgeEditor(); 22 - $editor->setSuppressEvents(true); 23 22 foreach ($unsubscribed as $user_phid => $_) { 24 23 $editor->addEdge( 25 24 $rev['phid'],
+2 -2
resources/sql/patches/20130409.commitdrev.php
··· 3 3 echo "Migrating differential.revisionPHID to edges...\n"; 4 4 $commit_table = new PhabricatorRepositoryCommit(); 5 5 $data_table = new PhabricatorRepositoryCommitData(); 6 - $editor = id(new PhabricatorEdgeEditor())->setSuppressEvents(true); 6 + $editor = new PhabricatorEdgeEditor(); 7 7 $commit_table->establishConnection('w'); 8 8 $edges = 0; 9 9 ··· 24 24 if ($edges % 256 == 0) { 25 25 echo '.'; 26 26 $editor->save(); 27 - $editor = id(new PhabricatorEdgeEditor())->setSuppressEvents(true); 27 + $editor = new PhabricatorEdgeEditor(); 28 28 } 29 29 } 30 30
+1 -3
resources/sql/patches/20131004.dxreviewers.php
··· 25 25 continue; 26 26 } 27 27 28 - $editor = id(new PhabricatorEdgeEditor()) 29 - ->setActor(PhabricatorUser::getOmnipotentUser()); 30 - 28 + $editor = new PhabricatorEdgeEditor(); 31 29 foreach ($reviewer_phids as $dst) { 32 30 if (phid_get_type($dst) == PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) { 33 31 // At least one old install ran into some issues here. Skip the row if we
-1
resources/sql/patches/20131121.repocredentials.2.mig.php
··· 121 121 $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_USES_CREDENTIAL; 122 122 123 123 id(new PhabricatorEdgeEditor()) 124 - ->setActor($viewer) 125 124 ->addEdge($repository->getPHID(), $edge_type, $credential->getPHID()) 126 125 ->save(); 127 126 }
-1
resources/sql/patches/migrate-differential-dependencies.php
··· 15 15 } 16 16 17 17 $editor = new PhabricatorEdgeEditor(); 18 - $editor->setSuppressEvents(true); 19 18 foreach ($deps as $dep) { 20 19 $editor->addEdge( 21 20 $rev->getPHID(),
-1
resources/sql/patches/migrate-maniphest-dependencies.php
··· 15 15 } 16 16 17 17 $editor = new PhabricatorEdgeEditor(); 18 - $editor->setSuppressEvents(true); 19 18 foreach ($deps as $dep) { 20 19 $editor->addEdge( 21 20 $task->getPHID(),
-1
resources/sql/patches/migrate-maniphest-revisions.php
··· 15 15 } 16 16 17 17 $editor = new PhabricatorEdgeEditor(); 18 - $editor->setSuppressEvents(true); 19 18 foreach ($revs as $rev) { 20 19 $editor->addEdge( 21 20 $task->getPHID(),
-1
resources/sql/patches/migrate-project-edges.php
··· 22 22 $members = ipull($members, 'userPHID'); 23 23 24 24 $editor = new PhabricatorEdgeEditor(); 25 - $editor->setSuppressEvents(true); 26 25 foreach ($members as $user_phid) { 27 26 $editor->addEdge( 28 27 $proj->getPHID(),
+1 -1
src/__phutil_library_map__.php
··· 4357 4357 'PhabricatorDraftDAO' => 'PhabricatorLiskDAO', 4358 4358 'PhabricatorEdgeConfig' => 'PhabricatorEdgeConstants', 4359 4359 'PhabricatorEdgeCycleException' => 'Exception', 4360 - 'PhabricatorEdgeEditor' => 'PhabricatorEditor', 4360 + 'PhabricatorEdgeEditor' => 'Phobject', 4361 4361 'PhabricatorEdgeGraph' => 'AbstractDirectedGraph', 4362 4362 'PhabricatorEdgeQuery' => 'PhabricatorQuery', 4363 4363 'PhabricatorEdgeTestCase' => 'PhabricatorTestCase',
+1 -2
src/applications/conpherence/editor/ConpherenceEditor.php
··· 216 216 217 217 switch ($xaction->getTransactionType()) { 218 218 case ConpherenceTransactionType::TYPE_FILES: 219 - $editor = id(new PhabricatorEdgeEditor()) 220 - ->setActor($this->getActor()); 219 + $editor = new PhabricatorEdgeEditor(); 221 220 $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE; 222 221 $old = array_fill_keys($xaction->getOldValue(), true); 223 222 $new = array_fill_keys($xaction->getNewValue(), true);
+1 -2
src/applications/differential/customfield/DifferentialJIRAIssuesField.php
··· 257 257 $revision_phid, 258 258 $edge_type); 259 259 260 - $editor = id(new PhabricatorEdgeEditor()) 261 - ->setActor($this->getViewer()); 260 + $editor = new PhabricatorEdgeEditor(); 262 261 263 262 foreach (array_diff($edges, $edge_dsts) as $rem_edge) { 264 263 $editor->removeEdge($revision_phid, $edge_type, $rem_edge);
+2 -2
src/applications/diffusion/controller/DiffusionCommitEditController.php
··· 34 34 $new_proj_phids = array_values($proj_phids); 35 35 $rem_proj_phids = array_diff($current_proj_phids, 36 36 $new_proj_phids); 37 - $editor = id(new PhabricatorEdgeEditor()); 38 - $editor->setActor($user); 37 + 38 + $editor = id(new PhabricatorEdgeEditor()); 39 39 foreach ($rem_proj_phids as $phid) { 40 40 $editor->removeEdge($commit_phid, $edge_type, $phid); 41 41 }
+1 -3
src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php
··· 235 235 ); 236 236 237 237 id(new PhabricatorEdgeEditor()) 238 - ->setActor($viewer) 239 238 ->addEdge($src_phid, $etype_main, $dst_phid, $edge_options) 240 239 ->save(); 241 240 ··· 247 246 248 247 // Now, handle the subtasks. 249 248 250 - $sub_editor = id(new PhabricatorEdgeEditor()) 251 - ->setActor($viewer); 249 + $sub_editor = new PhabricatorEdgeEditor(); 252 250 253 251 // First, find all the object references in Phabricator for tasks that we 254 252 // know about and import their objects from Asana.
-2
src/applications/files/storage/PhabricatorFile.php
··· 859 859 $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE; 860 860 861 861 id(new PhabricatorEdgeEditor()) 862 - ->setActor($actor) 863 - ->setSuppressEvents(true) 864 862 ->addEdge($phid, $edge_type, $this->getPHID()) 865 863 ->save(); 866 864
-1
src/applications/legalpad/editor/LegalpadDocumentEditor.php
··· 105 105 $type = PhabricatorEdgeConfig::TYPE_CONTRIBUTED_TO_OBJECT; 106 106 id(new PhabricatorEdgeEditor()) 107 107 ->addEdge($actor->getPHID(), $type, $object->getPHID()) 108 - ->setActor($actor) 109 108 ->save(); 110 109 111 110 $type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_CONTRIBUTOR;
-1
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 330 330 331 331 if ($parent_task) { 332 332 id(new PhabricatorEdgeEditor()) 333 - ->setActor($user) 334 333 ->addEdge( 335 334 $parent_task->getPHID(), 336 335 PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK,
+1 -4
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 225 225 return; 226 226 } 227 227 228 - $editor = id(new PhabricatorEdgeEditor()) 229 - ->setActor($this->getActor()) 230 - ->setSuppressEvents(true); 231 - 228 + $editor = new PhabricatorEdgeEditor(); 232 229 foreach ($add as $phid) { 233 230 $editor->addEdge($src, $edge_type, $phid); 234 231 }
-1
src/applications/ponder/editor/PonderVoteEditor.php
··· 34 34 // prepare vote add, or update if this user is amending an 35 35 // earlier vote 36 36 $editor = id(new PhabricatorEdgeEditor()) 37 - ->setActor($actor) 38 37 ->addEdge( 39 38 $actor->getPHID(), 40 39 $votable->getUserVoteEdgeType(),
+1 -2
src/applications/project/editor/PhabricatorProjectTransactionEditor.php
··· 231 231 232 232 if ($rem) { 233 233 // When removing members, also remove any watches on the project. 234 - $edge_editor = id(new PhabricatorEdgeEditor()) 235 - ->setSuppressEvents(true); 234 + $edge_editor = new PhabricatorEdgeEditor(); 236 235 foreach ($rem as $rem_phid) { 237 236 $edge_editor->removeEdge( 238 237 $object->getPHID(),
+1 -2
src/applications/repository/editor/PhabricatorRepositoryEditor.php
··· 225 225 $old_phid = $xaction->getOldValue(); 226 226 $new_phid = $xaction->getNewValue(); 227 227 228 - $editor = id(new PhabricatorEdgeEditor()) 229 - ->setActor($this->requireActor()); 228 + $editor = new PhabricatorEdgeEditor(); 230 229 231 230 $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_USES_CREDENTIAL; 232 231 $src_phid = $object->getPHID();
-2
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 90 90 if ($revision) { 91 91 $commit_drev = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV; 92 92 id(new PhabricatorEdgeEditor()) 93 - ->setActor($user) 94 93 ->addEdge($commit->getPHID(), $commit_drev, $revision->getPHID()) 95 94 ->save(); 96 95 ··· 453 452 // Maniphest edges is sorted out. Currently, Maniphest reacts to an edge 454 453 // edit on this edge. 455 454 id(new PhabricatorEdgeEditor()) 456 - ->setActor($actor) 457 455 ->addEdge( 458 456 $task->getPHID(), 459 457 PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT,
+1 -2
src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php
··· 83 83 $u_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER; 84 84 $s_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER; 85 85 86 - $editor = id(new PhabricatorEdgeEditor()) 87 - ->setActor($actor); 86 + $editor = new PhabricatorEdgeEditor(); 88 87 89 88 foreach ($add as $phid => $ignored) { 90 89 $editor->removeEdge($src, $u_type, $phid);
+1 -2
src/applications/system/engine/PhabricatorDestructionEngine.php
··· 62 62 return; 63 63 } 64 64 65 - $editor = id(new PhabricatorEdgeEditor()) 66 - ->setSuppressEvents(true); 65 + $editor = new PhabricatorEdgeEditor(); 67 66 foreach ($edges as $type => $type_edges) { 68 67 foreach ($type_edges as $src => $src_edges) { 69 68 foreach ($src_edges as $dst => $edge) {
+1 -7
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 411 411 $new[$dst_phid]['src'] = $src; 412 412 } 413 413 414 - $editor = id(new PhabricatorEdgeEditor()) 415 - ->setActor($this->getActor()); 414 + $editor = new PhabricatorEdgeEditor(); 416 415 417 416 foreach ($old as $dst_phid => $edge) { 418 417 if (!empty($new[$dst_phid])) { ··· 2345 2344 2346 2345 $editor = id(new PhabricatorEdgeEditor()) 2347 2346 ->setActor($this->getActor()); 2348 - 2349 - // TODO: Edge-based events were almost certainly a terrible idea. If we 2350 - // don't suppress this event, the Maniphest listener reenters and adds 2351 - // more transactions. Just suppress it until that can get cleaned up. 2352 - $editor->setSuppressEvents(true); 2353 2347 2354 2348 $src = $object->getPHID(); 2355 2349 $type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE;
-34
src/docs/user/userguide/events.diviner
··· 236 236 237 237 Using @{class@libphutil:PhutilEmailAddress} may be helpful in parsing the query. 238 238 239 - == Edge: Will Edit Edges == 240 - 241 - NOTE: Edge events are low-level events deep in the core. It is more difficult to 242 - correct implement listeners for these events than for higher-level events. 243 - 244 - The constant for this event is 245 - `PhabricatorEventType::TYPE_EDGE_WILLEDITEDGES`. 246 - 247 - This event is dispatched before @{class:PhabricatorEdgeEditor} makes an edge 248 - edit. 249 - 250 - - `id` An identifier for this edit operation. 251 - - `add` A list of dictionaries, each representing a new edge. 252 - - `rem` A list of dictionaries, each representing a removed edge. 253 - 254 - This is similar to the next event (did edit edges) but occurs before the 255 - edit begins. 256 - 257 - == Edge: Did Edit Edges == 258 - 259 - The constant for this event is 260 - `PhabricatorEventType::TYPE_EDGE_DIDEDITEDGES`. 261 - 262 - This event is dispatched after @{class:PhabricatorEdgeEditor} makes an edge 263 - edit, but before it commits the transactions. Data available on this event: 264 - 265 - - `id` An identifier for this edit operation. This is the same ID as 266 - the one included in the corresponding "will edit edges" event. 267 - - `add` A list of dictionaries, each representing a new edge. 268 - - `rem` A list of dictionaries, each representing a removed edge. 269 - 270 - This is similar to the previous event (will edit edges) but occurs after the 271 - edit completes. 272 - 273 239 == Search: Did Update Index == 274 240 275 241 The constant for this event is
-3
src/infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php
··· 21 21 $phid2 = $obj2->getPHID(); 22 22 23 23 $editor = id(new PhabricatorEdgeEditor()) 24 - ->setActor($user) 25 24 ->addEdge($phid1, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid2) 26 25 ->addEdge($phid2, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid1); 27 26 ··· 39 38 // fail (it introduces a cycle). 40 39 41 40 $editor = id(new PhabricatorEdgeEditor()) 42 - ->setActor($user) 43 41 ->addEdge($phid1, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid2) 44 42 ->save(); 45 43 46 44 $editor = id(new PhabricatorEdgeEditor()) 47 - ->setActor($user) 48 45 ->addEdge($phid2, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid1); 49 46 50 47 $caught = null;
+4 -38
src/infrastructure/edges/editor/PhabricatorEdgeEditor.php
··· 5 5 * @{class:PhabricatorEdgeQuery} to load object edges. For more information 6 6 * on edges, see @{article:Using Edges}. 7 7 * 8 + * Edges are not directly policy aware, and this editor makes low-level changes 9 + * below the policy layer. 10 + * 8 11 * name=Adding Edges 9 12 * $src = $earth_phid; 10 13 * $type = PhabricatorEdgeConfig::TYPE_BODY_HAS_SATELLITE; ··· 12 15 * 13 16 * id(new PhabricatorEdgeEditor()) 14 17 * ->addEdge($src, $type, $dst) 15 - * ->setActor($user) 16 18 * ->save(); 17 19 * 18 20 * @task edit Editing Edges 19 21 * @task cycles Cycle Prevention 20 22 * @task internal Internals 21 23 */ 22 - final class PhabricatorEdgeEditor extends PhabricatorEditor { 24 + final class PhabricatorEdgeEditor extends Phobject { 23 25 24 26 private $addEdges = array(); 25 27 private $remEdges = array(); 26 28 private $openTransactions = array(); 27 - private $suppressEvents; 28 29 29 30 30 31 /* -( Editing Edges )------------------------------------------------------ */ ··· 118 119 static $id = 0; 119 120 $id++; 120 121 121 - $this->sendEvent($id, PhabricatorEventType::TYPE_EDGE_WILLEDITEDGES); 122 - 123 122 // NOTE: Removes first, then adds, so that "remove + add" is a useful 124 123 // operation meaning "overwrite". 125 124 ··· 129 128 foreach ($cycle_types as $cycle_type) { 130 129 $this->detectCycles($src_phids, $cycle_type); 131 130 } 132 - 133 - $this->sendEvent($id, PhabricatorEventType::TYPE_EDGE_DIDEDITEDGES); 134 131 135 132 $this->saveTransactions(); 136 133 } catch (Exception $ex) { ··· 349 346 $conn_w->killTransaction(); 350 347 unset($this->openTransactions[$key]); 351 348 } 352 - } 353 - 354 - /** 355 - * Suppress edge edit events. This prevents listeners from making updates in 356 - * response to edits, and is primarily useful when performing migrations. You 357 - * should not normally need to use it. 358 - * 359 - * @param bool True to suppress events related to edits. 360 - * @return this 361 - * @task internal 362 - */ 363 - public function setSuppressEvents($suppress) { 364 - $this->suppressEvents = $suppress; 365 - return $this; 366 - } 367 - 368 - 369 - private function sendEvent($edit_id, $event_type) { 370 - if ($this->suppressEvents) { 371 - return; 372 - } 373 - 374 - $event = new PhabricatorEvent( 375 - $event_type, 376 - array( 377 - 'id' => $edit_id, 378 - 'add' => $this->addEdges, 379 - 'rem' => $this->remEdges, 380 - )); 381 - $event->setUser($this->getActor()); 382 - PhutilEventEngine::dispatchEvent($event); 383 349 } 384 350 385 351
-3
src/infrastructure/events/constant/PhabricatorEventType.php
··· 16 16 const TYPE_DIFFUSION_DIDDISCOVERCOMMIT = 'diffusion.didDiscoverCommit'; 17 17 const TYPE_DIFFUSION_LOOKUPUSER = 'diffusion.lookupUser'; 18 18 19 - const TYPE_EDGE_WILLEDITEDGES = 'edge.willEditEdges'; 20 - const TYPE_EDGE_DIDEDITEDGES = 'edge.didEditEdges'; 21 - 22 19 const TYPE_TEST_DIDRUNTEST = 'test.didRunTest'; 23 20 24 21 const TYPE_UI_DIDRENDERACTIONS = 'ui.didRenderActions';