mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
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
This commit is contained in:
parent
ca83e4c6a8
commit
7deec8208f
2 changed files with 16 additions and 23 deletions
|
@ -152,7 +152,9 @@ final class ManiphestTransactionEditor
|
|||
case ManiphestTransaction::TYPE_CCS:
|
||||
return $object->setCCPHIDs($xaction->getNewValue());
|
||||
case ManiphestTransaction::TYPE_PROJECTS:
|
||||
return $object->setProjectPHIDs($xaction->getNewValue());
|
||||
$object->setProjectPHIDs($xaction->getNewValue());
|
||||
ManiphestTaskProject::updateTaskProjects($object);
|
||||
return $object;
|
||||
case ManiphestTransaction::TYPE_EDGE:
|
||||
// These are a weird, funky mess and are already being applied by the
|
||||
// time we reach this.
|
||||
|
@ -415,19 +417,6 @@ final class ManiphestTransactionEditor
|
|||
$existing_cc = $object->getCCPHIDs();
|
||||
$new_cc = array_unique(array_merge($cc_phids, $existing_cc));
|
||||
$object->setCCPHIDs($new_cc);
|
||||
$save_again = true;
|
||||
}
|
||||
|
||||
$project_phids = $adapter->getProjectPHIDs();
|
||||
if ($project_phids) {
|
||||
$existing_projects = $object->getProjectPHIDs();
|
||||
$new_projects = array_unique(
|
||||
array_merge($project_phids, $existing_projects));
|
||||
$object->setProjectPHIDs($new_projects);
|
||||
$save_again = true;
|
||||
}
|
||||
|
||||
if ($save_again) {
|
||||
$object->save();
|
||||
}
|
||||
|
||||
|
@ -442,6 +431,19 @@ final class ManiphestTransactionEditor
|
|||
->setNewValue($assign_phid);
|
||||
}
|
||||
|
||||
$project_phids = $adapter->getProjectPHIDs();
|
||||
if ($project_phids) {
|
||||
$existing_projects = $object->getProjectPHIDs();
|
||||
$new_projects = array_unique(
|
||||
array_merge(
|
||||
$project_phids,
|
||||
$existing_projects));
|
||||
|
||||
$xactions[] = id(new ManiphestTransaction())
|
||||
->setTransactionType(ManiphestTransaction::TYPE_PROJECTS)
|
||||
->setNewValue($new_projects);
|
||||
}
|
||||
|
||||
return $xactions;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ final class ManiphestTask extends ManiphestDAO
|
|||
|
||||
protected $attached = array();
|
||||
protected $projectPHIDs = array();
|
||||
private $projectsNeedUpdate;
|
||||
private $subscribersNeedUpdate;
|
||||
|
||||
protected $ownerOrdering;
|
||||
|
@ -92,7 +91,6 @@ final class ManiphestTask extends ManiphestDAO
|
|||
|
||||
public function setProjectPHIDs(array $phids) {
|
||||
$this->projectPHIDs = array_values($phids);
|
||||
$this->projectsNeedUpdate = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -140,13 +138,6 @@ final class ManiphestTask extends ManiphestDAO
|
|||
|
||||
$result = parent::save();
|
||||
|
||||
if ($this->projectsNeedUpdate) {
|
||||
// If we've changed the project PHIDs for this task, update the link
|
||||
// table.
|
||||
ManiphestTaskProject::updateTaskProjects($this);
|
||||
$this->projectsNeedUpdate = false;
|
||||
}
|
||||
|
||||
if ($this->subscribersNeedUpdate) {
|
||||
// If we've changed the subscriber PHIDs for this task, update the link
|
||||
// table.
|
||||
|
|
Loading…
Reference in a new issue