@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Maniphest - introduce needProjectPHIDs

Summary: Ref T5245. This is some of the associated cleanup there.

Test Plan:
foreach ManiphestTaskQuery site, I made the change (or not) and tested as follows:

=== Call sites where added needProjectPHIDs ===

- PhabricatorHomeMainController - loaded the home page
- ManiphestBatchEditController - batch edited some tasks (added a project)
- ManiphestConduitAPIMethod - tested implicitly when tested ManiphestUpdateConduitAPIMethod
- ManiphestInfoConduitAPIMethod - used the method via conduit console with input id : 1
- ManiphestQueryConduitAPIMethod - used the method via conduit console with input ids : [1, 2]
- ManiphestUpdateConduitAPIMethod - used the method via conduit with input id : 1 and comment : “asdasds"
- ManiphestReportController - viewed “By User” and “By Project”
- ManiphestSubpriorityController - changed the priority of a task via a drag on manphest home
- ManiphestTaskMailReceiver - updated Task 1 via bin/mail receive-test with a comment that is the README
- ManiphestTaskSearchEngine - loaded Manifest home page
- ManiphestTaskEditController - edited a task
- ManiphestTransactionEditor - closed a blocking task
- ManiphestTransactionSaveController - commented on a task
- PhabricatorProjectProfileController - viewed project with id of 1 that has a few tasks in it
- PhabricatorSearchAttachController - merged tasks together
- DifferentialTransactionEditor - submit a diff that references a task; commit the diff (thus closing the diff) and the task gets updated
- PhabricatorRepositoryCommitMessageParserWorker - submit a diff that references a task; commit the diff (thus closing the diff) and the task gets updated

=== Calls sites where *did not* add needProjectPHIDs (they do not appear in this revision) ===

- PhabricatorManiphestApplication - loaded the home page
- ManiphestGetTaskTransactionsConduitAPIMethod - used the method via conduit console with input ids : [1, 2] ManiphestTaskDetailController - viewed a task with and without associated projects; finished workflow creating a task with a parent
- ManiphestTransactionPreviewController - verified transaction preview showed up properly
- PhabricatorProjectBoardViewController - viewed a board
- PhabricatorProjectMoveController - moved a task around
- ManiphestRemarkupRule - made a task reference like {T123}
- ManiphestTaskQuery - executed a custom query for all tasks with page size of 2 and paginated through some tasks
- ManiphestTaskPHIDType - nothing random seems broken? =D

=== Call sites where had to do something funky ===

- ManiphestHovercardEventListener - loaded hover cards from task mentions

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T5245

Differential Revision: https://secure.phabricator.com/D11004

+64 -42
+3
src/applications/home/controller/PhabricatorHomeMainController.php
··· 130 130 ->setViewer($user) 131 131 ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 132 132 ->withPriorities(array($unbreak_now)) 133 + ->needProjectPHIDs(true) 133 134 ->setLimit(10); 134 135 135 136 $tasks = $task_query->execute(); ··· 173 174 ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 174 175 ->withPriorities(array($needs_triage)) 175 176 ->withAnyProjects(mpull($projects, 'getPHID')) 177 + ->needProjectPHIDs(true) 176 178 ->setLimit(10); 177 179 $tasks = $task_query->execute(); 178 180 } else { ··· 269 271 ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 270 272 ->setGroupBy(ManiphestTaskQuery::GROUP_PRIORITY) 271 273 ->withOwners(array($user_phid)) 274 + ->needProjectPHIDs(true) 272 275 ->setLimit(10); 273 276 274 277 $tasks = $task_query->execute();
+1
src/applications/maniphest/conduit/ManiphestConduitAPIMethod.php
··· 237 237 ->setViewer($request->getUser()) 238 238 ->withPHIDs(array($task->getPHID())) 239 239 ->needSubscriberPHIDs(true) 240 + ->needProjectPHIDs(true) 240 241 ->executeOne(); 241 242 } 242 243
+1
src/applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php
··· 33 33 ->setViewer($request->getUser()) 34 34 ->withIDs(array($task_id)) 35 35 ->needSubscriberPHIDs(true) 36 + ->needProjectPHIDs(true) 36 37 ->executeOne(); 37 38 if (!$task) { 38 39 throw new ConduitException('ERR_BAD_TASK');
+4 -4
src/applications/maniphest/conduit/ManiphestQueryConduitAPIMethod.php
··· 61 61 } 62 62 63 63 protected function execute(ConduitAPIRequest $request) { 64 - $query = new ManiphestTaskQuery(); 65 - 66 - $query->setViewer($request->getUser()); 67 - $query->needSubscriberPHIDs(true); 64 + $query = id(new ManiphestTaskQuery()) 65 + ->setViewer($request->getUser()) 66 + ->needProjectPHIDs(true) 67 + ->needSubscriberPHIDs(true); 68 68 69 69 $task_ids = $request->getValue('ids'); 70 70 if ($task_ids) {
+7 -10
src/applications/maniphest/conduit/ManiphestUpdateConduitAPIMethod.php
··· 34 34 throw new Exception("Specify exactly one of 'id' and 'phid'."); 35 35 } 36 36 37 + $query = id (new ManiphestTaskQuery()) 38 + ->setViewer($request->getUser()) 39 + ->needSubscriberPHIDs(true) 40 + ->needProjectPHIDs(true); 37 41 if ($id) { 38 - $task = id(new ManiphestTaskQuery()) 39 - ->setViewer($request->getUser()) 40 - ->withIDs(array($id)) 41 - ->needSubscriberPHIDs(true) 42 - ->executeOne(); 42 + $query->withIDs(array($id)); 43 43 } else { 44 - $task = id(new ManiphestTaskQuery()) 45 - ->setViewer($request->getUser()) 46 - ->withPHIDs(array($phid)) 47 - ->needSubscriberPHIDs(true) 48 - ->executeOne(); 44 + $query->withPHIDs(array($phid)); 49 45 } 46 + $task = $query->executeOne(); 50 47 51 48 $params = $request->getAllParameters(); 52 49 unset($params['id']);
+1
src/applications/maniphest/controller/ManiphestBatchEditController.php
··· 19 19 PhabricatorPolicyCapability::CAN_EDIT, 20 20 )) 21 21 ->needSubscriberPHIDs(true) 22 + ->needProjectPHIDs(true) 22 23 ->execute(); 23 24 24 25 $actions = $request->getStr('actions');
+6
src/applications/maniphest/controller/ManiphestReportController.php
··· 396 396 ->setViewer($user) 397 397 ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()); 398 398 399 + switch ($this->view) { 400 + case 'project': 401 + $query->needProjectPHIDs(true); 402 + break; 403 + } 404 + 399 405 $project_phid = $request->getStr('project'); 400 406 $project_handle = null; 401 407 if ($project_phid) {
+1
src/applications/maniphest/controller/ManiphestSubpriorityController.php
··· 13 13 $task = id(new ManiphestTaskQuery()) 14 14 ->setViewer($user) 15 15 ->withIDs(array($request->getInt('task'))) 16 + ->needProjectPHIDs(true) 16 17 ->requireCapabilities( 17 18 array( 18 19 PhabricatorPolicyCapability::CAN_VIEW,
+2
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 39 39 )) 40 40 ->withIDs(array($this->id)) 41 41 ->needSubscriberPHIDs(true) 42 + ->needProjectPHIDs(true) 42 43 ->executeOne(); 43 44 if (!$task) { 44 45 return new Aphront404Response(); ··· 446 447 ->setViewer($user) 447 448 ->withIDs(array($template_id)) 448 449 ->needSubscriberPHIDs(true) 450 + ->needProjectPHIDs(true) 449 451 ->executeOne(); 450 452 if ($template_task) { 451 453 $cc_phids = array_unique(array_merge(
+1
src/applications/maniphest/controller/ManiphestTransactionSaveController.php
··· 10 10 ->setViewer($user) 11 11 ->withIDs(array($request->getStr('taskID'))) 12 12 ->needSubscriberPHIDs(true) 13 + ->needProjectPHIDs(true) 13 14 ->executeOne(); 14 15 if (!$task) { 15 16 return new Aphront404Response();
+1
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 370 370 ->setViewer($this->getActor()) 371 371 ->withPHIDs($blocked_phids) 372 372 ->needSubscriberPHIDs(true) 373 + ->needProjectPHIDs(true) 373 374 ->execute(); 374 375 375 376 $old = $unblock_xaction->getOldValue();
+6 -11
src/applications/maniphest/event/ManiphestHovercardEventListener.php
··· 25 25 return; 26 26 } 27 27 28 + $e_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 28 29 // Fun with "Unbeta Pholio", hua hua 29 30 $e_dep_on = PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK; 30 31 $e_dep_by = PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK; ··· 33 34 ->withSourcePHIDs(array($phid)) 34 35 ->withEdgeTypes( 35 36 array( 37 + $e_project, 36 38 $e_dep_on, 37 39 $e_dep_by, 38 40 )); ··· 40 42 $edge_phids = $edge_query->getDestinationPHIDs(); 41 43 42 44 $owner_phid = $task->getOwnerPHID(); 43 - $project_phids = $task->getProjectPHIDs(); 44 45 45 46 $phids = array_filter(array_merge( 46 47 array($owner_phid), 47 - $edge_phids, 48 - $project_phids)); 48 + $edge_phids)); 49 49 50 50 $viewer_handles = $this->loadHandles($phids, $viewer); 51 51 ··· 58 58 } 59 59 60 60 $hovercard->addField(pht('Assigned to'), $owner); 61 - if ($project_phids) { 62 - $hovercard->addField(pht('Projects'), 63 - implode_selected_handle_links(', ', $viewer_handles, $project_phids)); 64 - } 65 61 66 62 if ($edge_phids) { 67 63 $edge_types = array( 68 - PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK 69 - => pht('Dependent Tasks'), 70 - PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK 71 - => pht('Depends On'), 64 + $e_project => pht('Projects'), 65 + $e_dep_by => pht('Dependent Tasks'), 66 + $e_dep_on => pht('Depends On'), 72 67 ); 73 68 74 69 $max_count = 6;
+1
src/applications/maniphest/mail/ManiphestTaskMailReceiver.php
··· 18 18 ->setViewer($viewer) 19 19 ->withIDs(array($id)) 20 20 ->needSubscriberPHIDs(true) 21 + ->needProjectPHIDs(true) 21 22 ->execute(); 22 23 23 24 return head($results);
+19 -15
src/applications/maniphest/query/ManiphestTaskQuery.php
··· 51 51 const ORDER_TITLE = 'order-title'; 52 52 53 53 private $needSubscriberPHIDs; 54 + private $needProjectPHIDs; 54 55 55 56 const DEFAULT_PAGE_SIZE = 1000; 56 57 ··· 182 183 183 184 public function needSubscriberPHIDs($bool) { 184 185 $this->needSubscriberPHIDs = $bool; 186 + return $this; 187 + } 188 + 189 + public function needProjectPHIDs($bool) { 190 + $this->needProjectPHIDs = $bool; 185 191 return $this; 186 192 } 187 193 ··· 340 346 protected function didFilterPage(array $tasks) { 341 347 $phids = mpull($tasks, 'getPHID'); 342 348 343 - // TODO: Eventually, we should make this optional and introduce a 344 - // needProjectPHIDs() method, but for now there's a lot of code which 345 - // assumes the data is always populated. 346 - 347 - $edge_query = id(new PhabricatorEdgeQuery()) 348 - ->withSourcePHIDs($phids) 349 - ->withEdgeTypes( 350 - array( 351 - PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, 352 - )); 353 - $edge_query->execute(); 349 + if ($this->needProjectPHIDs) { 350 + $edge_query = id(new PhabricatorEdgeQuery()) 351 + ->withSourcePHIDs($phids) 352 + ->withEdgeTypes( 353 + array( 354 + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, 355 + )); 356 + $edge_query->execute(); 354 357 355 - foreach ($tasks as $task) { 356 - $project_phids = $edge_query->getDestinationPHIDs( 357 - array($task->getPHID())); 358 - $task->attachProjectPHIDs($project_phids); 358 + foreach ($tasks as $task) { 359 + $project_phids = $edge_query->getDestinationPHIDs( 360 + array($task->getPHID())); 361 + $task->attachProjectPHIDs($project_phids); 362 + } 359 363 } 360 364 361 365 if ($this->needSubscriberPHIDs) {
+2 -1
src/applications/maniphest/query/ManiphestTaskSearchEngine.php
··· 119 119 } 120 120 121 121 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 122 - $query = id(new ManiphestTaskQuery()); 122 + $query = id(new ManiphestTaskQuery()) 123 + ->needProjectPHIDs(true); 123 124 124 125 $author_phids = $saved->getParameter('authorPHIDs'); 125 126 if ($author_phids) {
+1
src/applications/project/controller/PhabricatorProjectProfileController.php
··· 143 143 ->withAnyProjects(array($project->getPHID())) 144 144 ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 145 145 ->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY) 146 + ->needProjectPHIDs(true) 146 147 ->setLimit(10); 147 148 $tasks = $query->execute(); 148 149
+1
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 459 459 $tasks = id(new ManiphestTaskQuery()) 460 460 ->setViewer($actor) 461 461 ->withIDs(array_keys($task_statuses)) 462 + ->needProjectPHIDs(true) 462 463 ->execute(); 463 464 464 465 foreach ($tasks as $task_id => $task) {
+6 -1
src/applications/search/controller/PhabricatorSearchAttachController.php
··· 144 144 ->setViewer($user) 145 145 ->withPHIDs(array_keys($phids)) 146 146 ->needSubscriberPHIDs(true) 147 + ->needProjectPHIDs(true) 147 148 ->execute(); 148 149 149 150 if (empty($targets)) { ··· 158 159 159 160 $cc_vector = array(); 160 161 // since we loaded this via a generic object query, go ahead and get the 161 - // attach the cc phids now 162 + // attach the subscriber and project phids now 162 163 $task->attachSubscriberPHIDs( 163 164 PhabricatorSubscribersQuery::loadSubscribersForPHID($task->getPHID())); 165 + $task->attachProjectPHIDs( 166 + PhabricatorEdgeQuery::loadDestinationPHIDs($task->getPHID(), 167 + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)); 168 + 164 169 $cc_vector[] = $task->getSubscriberPHIDs(); 165 170 foreach ($targets as $target) { 166 171 $cc_vector[] = $target->getSubscriberPHIDs();