Path: blob/master/src/infrastructure/edges/engineextension/PhabricatorEdgesDestructionEngineExtension.php
12242 views
<?php12final class PhabricatorEdgesDestructionEngineExtension3extends PhabricatorDestructionEngineExtension {45const EXTENSIONKEY = 'edges';67public function getExtensionName() {8return pht('Edges');9}1011public function destroyObject(12PhabricatorDestructionEngine $engine,13$object) {1415$src_phid = $object->getPHID();1617try {18$edges = id(new PhabricatorEdgeQuery())19->withSourcePHIDs(array($src_phid))20->execute();21} catch (Exception $ex) {22// This is (presumably) a "no edges for this PHID type" exception.23return;24}2526$editor = new PhabricatorEdgeEditor();27foreach ($edges as $type => $type_edges) {28foreach ($type_edges as $src => $src_edges) {29foreach ($src_edges as $dst => $edge) {30try {31$editor->removeEdge($edge['src'], $edge['type'], $edge['dst']);32} catch (Exception $ex) {33// We can run into an exception while removing the edge if the34// edge type no longer exists. This prevents us from figuring out35// if there's an inverse type. Just ignore any errors here and36// continue, since the best we can do is clean up all the edges37// we still have information about. See T11201.38phlog($ex);39}40}41}42}4344$editor->save();45}4647}484950