Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/edges/engineextension/PhabricatorEdgesDestructionEngineExtension.php
12242 views
1
<?php
2
3
final class PhabricatorEdgesDestructionEngineExtension
4
extends PhabricatorDestructionEngineExtension {
5
6
const EXTENSIONKEY = 'edges';
7
8
public function getExtensionName() {
9
return pht('Edges');
10
}
11
12
public function destroyObject(
13
PhabricatorDestructionEngine $engine,
14
$object) {
15
16
$src_phid = $object->getPHID();
17
18
try {
19
$edges = id(new PhabricatorEdgeQuery())
20
->withSourcePHIDs(array($src_phid))
21
->execute();
22
} catch (Exception $ex) {
23
// This is (presumably) a "no edges for this PHID type" exception.
24
return;
25
}
26
27
$editor = new PhabricatorEdgeEditor();
28
foreach ($edges as $type => $type_edges) {
29
foreach ($type_edges as $src => $src_edges) {
30
foreach ($src_edges as $dst => $edge) {
31
try {
32
$editor->removeEdge($edge['src'], $edge['type'], $edge['dst']);
33
} catch (Exception $ex) {
34
// We can run into an exception while removing the edge if the
35
// edge type no longer exists. This prevents us from figuring out
36
// if there's an inverse type. Just ignore any errors here and
37
// continue, since the best we can do is clean up all the edges
38
// we still have information about. See T11201.
39
phlog($ex);
40
}
41
}
42
}
43
}
44
45
$editor->save();
46
}
47
48
}
49
50