diff --git a/resources/sql/patches/migrate-maniphest-dependencies.php b/resources/sql/patches/migrate-maniphest-dependencies.php index 4e39e85987..51f1c944e9 100644 --- a/resources/sql/patches/migrate-maniphest-dependencies.php +++ b/resources/sql/patches/migrate-maniphest-dependencies.php @@ -8,7 +8,7 @@ foreach (new LiskMigrationIterator($table) as $task) { $id = $task->getID(); echo "Task {$id}: "; - $deps = $task->getAttachedPHIDs(PhabricatorPHIDConstants::PHID_TYPE_TASK); + $deps = $task->getAttachedPHIDs(ManiphestPHIDTypeTask::TYPECONST); if (!$deps) { echo "-\n"; continue; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 719a17bf77..79b5a3f93d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -684,6 +684,7 @@ phutil_register_library_map(array( 'ManiphestExcelFormat' => 'applications/maniphest/export/ManiphestExcelFormat.php', 'ManiphestExportController' => 'applications/maniphest/controller/ManiphestExportController.php', 'ManiphestHovercardEventListener' => 'applications/maniphest/event/ManiphestHovercardEventListener.php', + 'ManiphestPHIDTypeTask' => 'applications/maniphest/phid/ManiphestPHIDTypeTask.php', 'ManiphestPeopleMenuEventListener' => 'applications/maniphest/event/ManiphestPeopleMenuEventListener.php', 'ManiphestRemarkupRule' => 'applications/maniphest/remarkup/ManiphestRemarkupRule.php', 'ManiphestReplyHandler' => 'applications/maniphest/mail/ManiphestReplyHandler.php', @@ -2636,6 +2637,7 @@ phutil_register_library_map(array( 'ManiphestExcelDefaultFormat' => 'ManiphestExcelFormat', 'ManiphestExportController' => 'ManiphestController', 'ManiphestHovercardEventListener' => 'PhutilEventListener', + 'ManiphestPHIDTypeTask' => 'PhabricatorPHIDType', 'ManiphestPeopleMenuEventListener' => 'PhutilEventListener', 'ManiphestRemarkupRule' => 'PhabricatorRemarkupRuleObject', 'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler', diff --git a/src/applications/maniphest/ManiphestTaskQuery.php b/src/applications/maniphest/ManiphestTaskQuery.php index 9c849f7404..b1d14d3744 100644 --- a/src/applications/maniphest/ManiphestTaskQuery.php +++ b/src/applications/maniphest/ManiphestTaskQuery.php @@ -75,11 +75,23 @@ final class ManiphestTaskQuery extends PhabricatorQuery { return $this; } + public function withIDs(array $ids) { + $this->ids = $ids; + return $this; + } + + public function withPHIDs(array $phids) { + $this->taskPHIDs = $phids; + return $this; + } + + // TODO: Deprecated in favor of `withIDs()`. public function withTaskIDs(array $ids) { $this->taskIDs = $ids; return $this; } + // TODO: Deprecated in favor of `withPHIDs()`. public function withTaskPHIDs(array $phids) { $this->taskPHIDs = $phids; return $this; diff --git a/src/applications/maniphest/event/ManiphestEdgeEventListener.php b/src/applications/maniphest/event/ManiphestEdgeEventListener.php index 32a73210ce..12b467eaa4 100644 --- a/src/applications/maniphest/event/ManiphestEdgeEventListener.php +++ b/src/applications/maniphest/event/ManiphestEdgeEventListener.php @@ -101,7 +101,7 @@ final class ManiphestEdgeEventListener extends PhutilEventListener { $add_edges = $event->getValue('add'); $rem_edges = $event->getValue('rem'); - $type_task = PhabricatorPHIDConstants::PHID_TYPE_TASK; + $type_task = ManiphestPHIDTypeTask::TYPECONST; $all_edges = array_merge($add_edges, $rem_edges); $all_edges = $this->filterEdgesBySourceType($all_edges, $type_task); diff --git a/src/applications/maniphest/phid/ManiphestPHIDTypeTask.php b/src/applications/maniphest/phid/ManiphestPHIDTypeTask.php new file mode 100644 index 0000000000..b81bc354cf --- /dev/null +++ b/src/applications/maniphest/phid/ManiphestPHIDTypeTask.php @@ -0,0 +1,78 @@ +setViewer($query->getViewer()) + ->withPHIDs($phids) + ->execute(); + } + + public function loadHandles( + PhabricatorHandleQuery $query, + array $handles, + array $objects) { + + foreach ($handles as $phid => $handle) { + $task = $objects[$phid]; + $id = $task->getID(); + $title = $task->getTitle(); + + $handle->setName("T{$id}"); + $handle->setFullName("T{$id}: {$title}"); + $handle->setURI("/T{$id}"); + + if ($task->getStatus() != ManiphestTaskStatus::STATUS_OPEN) { + $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED); + } + } + } + + public function canLoadNamedObject($name) { + return preg_match('/^T\d*[1-9]\d*$/i', $name); + } + + public function loadNamedObjects( + PhabricatorObjectQuery $query, + array $names) { + + $id_map = array(); + foreach ($names as $name) { + $id = (int)substr($name, 1); + $id_map[$id][] = $name; + } + + $objects = id(new ManiphestTaskQuery()) + ->setViewer($query->getViewer()) + ->withIDs(array_keys($id_map)) + ->execute(); + + $results = array(); + foreach ($objects as $id => $object) { + foreach (idx($id_map, $id, array()) as $name) { + $results[$name] = $object; + } + } + + return $results; + } + +} diff --git a/src/applications/maniphest/search/ManiphestSearchIndexer.php b/src/applications/maniphest/search/ManiphestSearchIndexer.php index f2013a4ce6..5a133d3454 100644 --- a/src/applications/maniphest/search/ManiphestSearchIndexer.php +++ b/src/applications/maniphest/search/ManiphestSearchIndexer.php @@ -15,7 +15,7 @@ final class ManiphestSearchIndexer $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($task->getPHID()); - $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_TASK); + $doc->setDocumentType(ManiphestPHIDTypeTask::TYPECONST); $doc->setDocumentTitle($task->getTitle()); $doc->setDocumentCreated($task->getDateCreated()); $doc->setDocumentModified($task->getDateModified()); @@ -34,7 +34,7 @@ final class ManiphestSearchIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $task->getPHID(), - PhabricatorPHIDConstants::PHID_TYPE_TASK, + ManiphestPHIDTypeTask::TYPECONST, time()); } diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index 4c3d83ec2b..32314f4505 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -65,8 +65,7 @@ final class ManiphestTask extends ManiphestDAO } public function generatePHID() { - return PhabricatorPHID::generateNewPHID( - PhabricatorPHIDConstants::PHID_TYPE_TASK); + return PhabricatorPHID::generateNewPHID(ManiphestPHIDTypeTask::TYPECONST); } public function getCCPHIDs() { diff --git a/src/applications/maniphest/view/ManiphestTransactionDetailView.php b/src/applications/maniphest/view/ManiphestTransactionDetailView.php index 4809b5de79..374ba285cc 100644 --- a/src/applications/maniphest/view/ManiphestTransactionDetailView.php +++ b/src/applications/maniphest/view/ManiphestTransactionDetailView.php @@ -483,7 +483,7 @@ final class ManiphestTransactionDetailView extends ManiphestView { foreach (array( DifferentialPHIDTypeRevision::TYPECONST, - PhabricatorPHIDConstants::PHID_TYPE_TASK, + ManiphestPHIDTypeTask::TYPECONST, PhabricatorPHIDConstants::PHID_TYPE_FILE) as $attach_type) { $old = array_keys(idx($old_raw, $attach_type, array())); $new = array_keys(idx($new_raw, $attach_type, array())); @@ -654,7 +654,7 @@ final class ManiphestTransactionDetailView extends ManiphestView { return pht('Differential Revision(s)', $count); case PhabricatorPHIDConstants::PHID_TYPE_FILE: return pht('file(s)', $count); - case PhabricatorPHIDConstants::PHID_TYPE_TASK: + case ManiphestPHIDTypeTask::TYPECONST: return pht('Maniphest Task(s)', $count); } } diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php index de72591451..bdb21c15cc 100644 --- a/src/applications/phid/PhabricatorObjectHandle.php +++ b/src/applications/phid/PhabricatorObjectHandle.php @@ -109,7 +109,6 @@ final class PhabricatorObjectHandle static $map = array( PhabricatorPHIDConstants::PHID_TYPE_USER => 'User', - PhabricatorPHIDConstants::PHID_TYPE_TASK => 'Task', PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'Phriction Document', PhabricatorPHIDConstants::PHID_TYPE_MCRO => 'Image Macro', PhabricatorPHIDConstants::PHID_TYPE_MOCK => 'Pholio Mock', diff --git a/src/applications/phid/PhabricatorPHIDConstants.php b/src/applications/phid/PhabricatorPHIDConstants.php index 04c1777bf5..323ef1123e 100644 --- a/src/applications/phid/PhabricatorPHIDConstants.php +++ b/src/applications/phid/PhabricatorPHIDConstants.php @@ -3,7 +3,6 @@ final class PhabricatorPHIDConstants { const PHID_TYPE_USER = 'USER'; - const PHID_TYPE_TASK = 'TASK'; const PHID_TYPE_FILE = 'FILE'; const PHID_TYPE_PROJ = 'PROJ'; const PHID_TYPE_UNKNOWN = '????'; diff --git a/src/applications/phid/handle/PhabricatorObjectHandleData.php b/src/applications/phid/handle/PhabricatorObjectHandleData.php index d17878a886..0cca29c84e 100644 --- a/src/applications/phid/handle/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/PhabricatorObjectHandleData.php @@ -56,15 +56,6 @@ final class PhabricatorObjectHandleData { $phids); return mpull($users, null, 'getPHID'); - case PhabricatorPHIDConstants::PHID_TYPE_TASK: - // TODO: Update this to ManiphestTaskQuery, //especially// after we have - // policy-awareness - $task_dao = new ManiphestTask(); - $tasks = $task_dao->loadAllWhere( - 'phid IN (%Ls)', - $phids); - return mpull($tasks, null, 'getPHID'); - case PhabricatorPHIDConstants::PHID_TYPE_CONF: $config_dao = new PhabricatorConfigEntry(); $entries = $config_dao->loadAllWhere( @@ -318,28 +309,6 @@ final class PhabricatorObjectHandleData { } break; - case PhabricatorPHIDConstants::PHID_TYPE_TASK: - foreach ($phids as $phid) { - $handle = new PhabricatorObjectHandle(); - $handle->setPHID($phid); - $handle->setType($type); - if (empty($objects[$phid])) { - $handle->setName('Unknown Task'); - } else { - $task = $objects[$phid]; - $handle->setName('T'.$task->getID()); - $handle->setURI('/T'.$task->getID()); - $handle->setFullName('T'.$task->getID().': '.$task->getTitle()); - $handle->setComplete(true); - if ($task->getStatus() != ManiphestTaskStatus::STATUS_OPEN) { - $closed = PhabricatorObjectHandleStatus::STATUS_CLOSED; - $handle->setStatus($closed); - } - } - $handles[$phid] = $handle; - } - break; - case PhabricatorPHIDConstants::PHID_TYPE_CONF: foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); diff --git a/src/applications/phid/storage/PhabricatorPHID.php b/src/applications/phid/storage/PhabricatorPHID.php index 0266d0b1f5..94fc239224 100644 --- a/src/applications/phid/storage/PhabricatorPHID.php +++ b/src/applications/phid/storage/PhabricatorPHID.php @@ -44,9 +44,7 @@ final class PhabricatorPHID { return $name; } - if (preg_match('/^t(\d+)$/i', $name, $match)) { - $object = id(new ManiphestTask())->load($match[1]); - } else if (preg_match('/^m(\d+)$/i', $name, $match)) { + if (preg_match('/^m(\d+)$/i', $name, $match)) { $objects = id(new PholioMockQuery()) ->setViewer($viewer) ->withIDs(array($match[1])) diff --git a/src/applications/search/controller/PhabricatorSearchAttachController.php b/src/applications/search/controller/PhabricatorSearchAttachController.php index c620c4a8c1..a76429d7b3 100644 --- a/src/applications/search/controller/PhabricatorSearchAttachController.php +++ b/src/applications/search/controller/PhabricatorSearchAttachController.php @@ -202,7 +202,7 @@ final class PhabricatorSearchAttachController $noun = 'Revisions'; $selected = 'created'; break; - case PhabricatorPHIDConstants::PHID_TYPE_TASK: + case ManiphestPHIDTypeTask::TYPECONST: $noun = 'Tasks'; $selected = 'assigned'; break; @@ -270,7 +270,7 @@ final class PhabricatorSearchAttachController private function getEdgeType($src_type, $dst_type) { $t_cmit = PhabricatorRepositoryPHIDTypeCommit::TYPECONST; - $t_task = PhabricatorPHIDConstants::PHID_TYPE_TASK; + $t_task = ManiphestPHIDTypeTask::TYPECONST; $t_drev = DifferentialPHIDTypeRevision::TYPECONST; $t_mock = PhabricatorPHIDConstants::PHID_TYPE_MOCK; diff --git a/src/applications/search/controller/PhabricatorSearchController.php b/src/applications/search/controller/PhabricatorSearchController.php index 5373c62cd3..52009a106b 100644 --- a/src/applications/search/controller/PhabricatorSearchController.php +++ b/src/applications/search/controller/PhabricatorSearchController.php @@ -53,7 +53,7 @@ final class PhabricatorSearchController $query->setParameter('open', 1); $query->setParameter( 'type', - PhabricatorPHIDConstants::PHID_TYPE_TASK); + ManiphestPHIDTypeTask::TYPECONST); break; case PhabricatorSearchScope::SCOPE_WIKI: $query->setParameter( diff --git a/src/applications/search/controller/PhabricatorSearchSelectController.php b/src/applications/search/controller/PhabricatorSearchSelectController.php index cf48114d20..9cbef3d97a 100644 --- a/src/applications/search/controller/PhabricatorSearchSelectController.php +++ b/src/applications/search/controller/PhabricatorSearchSelectController.php @@ -67,7 +67,7 @@ final class PhabricatorSearchSelectController $pattern = null; switch ($this->type) { - case PhabricatorPHIDConstants::PHID_TYPE_TASK: + case ManiphestPHIDTypeTask::TYPECONST: $pattern = '/\bT(\d+)\b/i'; break; case DifferentialPHIDTypeRevision::TYPECONST: @@ -99,7 +99,7 @@ final class PhabricatorSearchSelectController 'id IN (%Ld)', $object_ids); break; - case PhabricatorPHIDConstants::PHID_TYPE_TASK: + case ManiphestPHIDTypeTask::TYPECONST: $objects = id(new ManiphestTask())->loadAllWhere( 'id IN (%Ld)', $object_ids); diff --git a/src/applications/search/index/PhabricatorSearchAbstractDocument.php b/src/applications/search/index/PhabricatorSearchAbstractDocument.php index b4baec4860..24f4357702 100644 --- a/src/applications/search/index/PhabricatorSearchAbstractDocument.php +++ b/src/applications/search/index/PhabricatorSearchAbstractDocument.php @@ -17,7 +17,7 @@ final class PhabricatorSearchAbstractDocument { return array( DifferentialPHIDTypeRevision::TYPECONST => 'Differential Revisions', PhabricatorRepositoryPHIDTypeCommit::TYPECONST => 'Repository Commits', - PhabricatorPHIDConstants::PHID_TYPE_TASK => 'Maniphest Tasks', + ManiphestPHIDTypeTask::TYPECONST => 'Maniphest Tasks', PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'Phriction Documents', PhabricatorPHIDConstants::PHID_TYPE_USER => 'Phabricator Users', PhabricatorPHIDConstants::PHID_TYPE_QUES => 'Ponder Questions', diff --git a/src/applications/uiexample/examples/PhabricatorHovercardExample.php b/src/applications/uiexample/examples/PhabricatorHovercardExample.php index f393143925..d319d55e41 100644 --- a/src/applications/uiexample/examples/PhabricatorHovercardExample.php +++ b/src/applications/uiexample/examples/PhabricatorHovercardExample.php @@ -33,7 +33,7 @@ final class PhabricatorHovercardExample extends PhabricatorUIExample { $task_handle = $this->createBasicDummyHandle( "T123", - PhabricatorPHIDConstants::PHID_TYPE_TASK, + ManiphestPHIDTypeTask::TYPECONST, "Improve Mobile Experience for Phabricator"); $tag = id(new PhabricatorTagView()) diff --git a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php index 0612c90c4c..f50f9c5223 100644 --- a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php +++ b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php @@ -154,7 +154,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { } static $class_map = array( - PhabricatorPHIDConstants::PHID_TYPE_TASK => 'ManiphestTask', PhabricatorPHIDConstants::PHID_TYPE_FILE => 'PhabricatorFile', PhabricatorPHIDConstants::PHID_TYPE_USER => 'PhabricatorUser', PhabricatorPHIDConstants::PHID_TYPE_PROJ => 'PhabricatorProject',