@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.

Make Maniphest project edits more transaction-oriented

Summary: Ref T5245. Currently, task/project links rely on side effects in `save()`. Make them more transaction-oriented, with the goal of moving fully to edges a few diffs down the line.

Test Plan:
- Added and removed projects using "Edit Task", "Associate Projects" comment action, and Herald.
- Verified database ended up in the expected state.

Reviewers: chad, btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T5245

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

+16 -23
+16 -14
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 152 152 case ManiphestTransaction::TYPE_CCS: 153 153 return $object->setCCPHIDs($xaction->getNewValue()); 154 154 case ManiphestTransaction::TYPE_PROJECTS: 155 - return $object->setProjectPHIDs($xaction->getNewValue()); 155 + $object->setProjectPHIDs($xaction->getNewValue()); 156 + ManiphestTaskProject::updateTaskProjects($object); 157 + return $object; 156 158 case ManiphestTransaction::TYPE_EDGE: 157 159 // These are a weird, funky mess and are already being applied by the 158 160 // time we reach this. ··· 415 417 $existing_cc = $object->getCCPHIDs(); 416 418 $new_cc = array_unique(array_merge($cc_phids, $existing_cc)); 417 419 $object->setCCPHIDs($new_cc); 418 - $save_again = true; 419 - } 420 - 421 - $project_phids = $adapter->getProjectPHIDs(); 422 - if ($project_phids) { 423 - $existing_projects = $object->getProjectPHIDs(); 424 - $new_projects = array_unique( 425 - array_merge($project_phids, $existing_projects)); 426 - $object->setProjectPHIDs($new_projects); 427 - $save_again = true; 428 - } 429 - 430 - if ($save_again) { 431 420 $object->save(); 432 421 } 433 422 ··· 440 429 $xactions[] = id(new ManiphestTransaction()) 441 430 ->setTransactionType(ManiphestTransaction::TYPE_OWNER) 442 431 ->setNewValue($assign_phid); 432 + } 433 + 434 + $project_phids = $adapter->getProjectPHIDs(); 435 + if ($project_phids) { 436 + $existing_projects = $object->getProjectPHIDs(); 437 + $new_projects = array_unique( 438 + array_merge( 439 + $project_phids, 440 + $existing_projects)); 441 + 442 + $xactions[] = id(new ManiphestTransaction()) 443 + ->setTransactionType(ManiphestTransaction::TYPE_PROJECTS) 444 + ->setNewValue($new_projects); 443 445 } 444 446 445 447 return $xactions;
-9
src/applications/maniphest/storage/ManiphestTask.php
··· 30 30 31 31 protected $attached = array(); 32 32 protected $projectPHIDs = array(); 33 - private $projectsNeedUpdate; 34 33 private $subscribersNeedUpdate; 35 34 36 35 protected $ownerOrdering; ··· 92 91 93 92 public function setProjectPHIDs(array $phids) { 94 93 $this->projectPHIDs = array_values($phids); 95 - $this->projectsNeedUpdate = true; 96 94 return $this; 97 95 } 98 96 ··· 139 137 } 140 138 141 139 $result = parent::save(); 142 - 143 - if ($this->projectsNeedUpdate) { 144 - // If we've changed the project PHIDs for this task, update the link 145 - // table. 146 - ManiphestTaskProject::updateTaskProjects($this); 147 - $this->projectsNeedUpdate = false; 148 - } 149 140 150 141 if ($this->subscribersNeedUpdate) { 151 142 // If we've changed the subscriber PHIDs for this task, update the link