Index: src/applications/maniphest/controller/ManiphestBatchEditController.php =================================================================== --- src/applications/maniphest/controller/ManiphestBatchEditController.php +++ src/applications/maniphest/controller/ManiphestBatchEditController.php @@ -55,8 +55,7 @@ ->setURI('/maniphest/?ids='.$task_ids); } - $handle_phids = mpull($tasks, 'getOwnerPHID'); - $handles = $this->loadViewerHandles($handle_phids); + $handles = ManiphestTaskListView::loadTaskHandles($user, $tasks); $list = new ManiphestTaskListView(); $list->setTasks($tasks); Index: src/applications/maniphest/controller/ManiphestTaskListController.php =================================================================== --- src/applications/maniphest/controller/ManiphestTaskListController.php +++ src/applications/maniphest/controller/ManiphestTaskListController.php @@ -40,7 +40,7 @@ $group_parameter = nonempty($query->getParameter('group'), 'priority'); $order_parameter = nonempty($query->getParameter('order'), 'priority'); - $handles = $this->loadTaskHandles($tasks); + $handles = ManiphestTaskListView::loadTaskHandles($viewer, $tasks); $groups = $this->groupTasks( $tasks, $group_parameter, @@ -114,30 +114,6 @@ )); } - private function loadTaskHandles(array $tasks) { - assert_instances_of($tasks, 'ManiphestTask'); - - $phids = array(); - foreach ($tasks as $task) { - $assigned_phid = $task->getOwnerPHID(); - if ($assigned_phid) { - $phids[] = $assigned_phid; - } - foreach ($task->getProjectPHIDs() as $project_phid) { - $phids[] = $project_phid; - } - } - - if (!$phids) { - return array(); - } - - return id(new PhabricatorHandleQuery()) - ->setViewer($this->getRequest()->getUser()) - ->withPHIDs($phids) - ->execute(); - } - private function groupTasks(array $tasks, $group, array $handles) { assert_instances_of($tasks, 'ManiphestTask'); assert_instances_of($handles, 'PhabricatorObjectHandle'); Index: src/applications/maniphest/view/ManiphestTaskListView.php =================================================================== --- src/applications/maniphest/view/ManiphestTaskListView.php +++ src/applications/maniphest/view/ManiphestTaskListView.php @@ -53,11 +53,8 @@ $item->setHref('/T'.$task->getID()); if ($task->getOwnerPHID()) { - $owner = idx($handles, $task->getOwnerPHID()); - // TODO: This should be guaranteed, see T3817. - if ($owner) { - $item->addByline(pht('Assigned: %s', $owner->renderLink())); - } + $owner = $handles[$task->getOwnerPHID()]; + $item->addByline(pht('Assigned: %s', $owner->renderLink())); } $status = $task->getStatus(); @@ -109,4 +106,30 @@ return $list; } + public static function loadTaskHandles( + PhabricatorUser $viewer, + array $tasks) { + assert_instances_of($tasks, 'ManiphestTask'); + + $phids = array(); + foreach ($tasks as $task) { + $assigned_phid = $task->getOwnerPHID(); + if ($assigned_phid) { + $phids[] = $assigned_phid; + } + foreach ($task->getProjectPHIDs() as $project_phid) { + $phids[] = $project_phid; + } + } + + if (!$phids) { + return array(); + } + + return id(new PhabricatorHandleQuery()) + ->setViewer($viewer) + ->withPHIDs($phids) + ->execute(); + } + }