diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index f544fa6b2c..34c7f54c11 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -87,12 +87,25 @@ final class ManiphestTaskDetailController extends ManiphestController { ->addPropertySection(pht('Description'), $description) ->addPropertySection(pht('Details'), $details); + $graph_limit = 100; $task_graph = id(new ManiphestTaskGraph()) ->setViewer($viewer) ->setSeedPHID($task->getPHID()) + ->setLimit($graph_limit) ->loadGraph(); if (!$task_graph->isEmpty()) { - $graph_table = $task_graph->newGraphTable(); + if ($task_graph->isOverLimit()) { + $message = pht( + 'Task graph too large to display (this task is connected to '. + 'more than %s other tasks).', + $graph_limit); + $message = phutil_tag('em', array(), $message); + $graph_table = id(new PHUIPropertyListView()) + ->addTextContent($message); + } else { + $graph_table = $task_graph->newGraphTable(); + } + $view->addPropertySection(pht('Task Graph'), $graph_table); } diff --git a/src/infrastructure/graph/PhabricatorObjectGraph.php b/src/infrastructure/graph/PhabricatorObjectGraph.php index 7a3790dea4..5e25cd8e33 100644 --- a/src/infrastructure/graph/PhabricatorObjectGraph.php +++ b/src/infrastructure/graph/PhabricatorObjectGraph.php @@ -9,6 +9,7 @@ abstract class PhabricatorObjectGraph private $seedPHID; private $objects; private $loadEntireGraph = false; + private $limit; public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; @@ -23,6 +24,15 @@ abstract class PhabricatorObjectGraph return $this->viewer; } + public function setLimit($limit) { + $this->limit = $limit; + return $this; + } + + public function getLimit() { + return $this->limit; + } + abstract protected function getEdgeTypes(); abstract protected function getParentEdgeType(); abstract protected function newQuery(); @@ -44,6 +54,16 @@ abstract class PhabricatorObjectGraph return (count($this->getNodes()) <= 2); } + final public function isOverLimit() { + $limit = $this->getLimit(); + + if (!$limit) { + return false; + } + + return (count($this->edgeReach) > $limit); + } + final public function getEdges($type) { $edges = idx($this->edges, $type, array()); @@ -72,6 +92,10 @@ abstract class PhabricatorObjectGraph } final protected function loadEdges(array $nodes) { + if ($this->isOverLimit()) { + return array_fill_keys($nodes, array()); + } + $edge_types = $this->getEdgeTypes(); $query = id(new PhabricatorEdgeQuery())