diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index 9eda17b7ee..a8c69cba24 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -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; } diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index 9477f6af7c..2a88ba9864 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -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.