mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Stop writing new TYPE_PROJECTS transactions to Maniphest
Summary: Ref T5245. We'll still display the old ones, but write real edge transactions now -- not TYPE_PROJECTS transactions. Some code remains to show the existing transactions. The next diff will modernize the old transactions so we can remove this code. Test Plan: - Previewed a project-editing comment. - Submitted a project-editing comment. - Edited a task's projects. - Batch edited a task's projects. Reviewers: joshuaspence, chad, btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9852
This commit is contained in:
parent
b8b59895ee
commit
e8c490958c
10 changed files with 82 additions and 84 deletions
|
@ -954,7 +954,6 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php',
|
'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php',
|
||||||
'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php',
|
'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php',
|
||||||
'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php',
|
'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php',
|
||||||
'ManiphestTaskProject' => 'applications/maniphest/storage/ManiphestTaskProject.php',
|
|
||||||
'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php',
|
'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php',
|
||||||
'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php',
|
'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php',
|
||||||
'ManiphestTaskSearchEngine' => 'applications/maniphest/query/ManiphestTaskSearchEngine.php',
|
'ManiphestTaskSearchEngine' => 'applications/maniphest/query/ManiphestTaskSearchEngine.php',
|
||||||
|
@ -3716,7 +3715,6 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTaskOwner' => 'ManiphestConstants',
|
'ManiphestTaskOwner' => 'ManiphestConstants',
|
||||||
'ManiphestTaskPriority' => 'ManiphestConstants',
|
'ManiphestTaskPriority' => 'ManiphestConstants',
|
||||||
'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource',
|
'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'ManiphestTaskProject' => 'ManiphestDAO',
|
|
||||||
'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'ManiphestTaskResultListView' => 'ManiphestView',
|
'ManiphestTaskResultListView' => 'ManiphestView',
|
||||||
'ManiphestTaskSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'ManiphestTaskSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
|
|
|
@ -116,18 +116,27 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod {
|
||||||
$changes[ManiphestTransaction::TYPE_CCS] = $ccs;
|
$changes[ManiphestTransaction::TYPE_CCS] = $ccs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$transactions = array();
|
||||||
|
|
||||||
$project_phids = $request->getValue('projectPHIDs');
|
$project_phids = $request->getValue('projectPHIDs');
|
||||||
if ($project_phids !== null) {
|
if ($project_phids !== null) {
|
||||||
$this->validatePHIDList(
|
$this->validatePHIDList(
|
||||||
$project_phids,
|
$project_phids,
|
||||||
PhabricatorProjectPHIDTypeProject::TYPECONST,
|
PhabricatorProjectPHIDTypeProject::TYPECONST,
|
||||||
'projectPHIDS');
|
'projectPHIDS');
|
||||||
$changes[ManiphestTransaction::TYPE_PROJECTS] = $project_phids;
|
|
||||||
|
$project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
|
$transactions[] = id(new ManiphestTransaction())
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $project_type)
|
||||||
|
->setNewValue(
|
||||||
|
array(
|
||||||
|
'=' => array_fuse($project_phids),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$template = new ManiphestTransaction();
|
$template = new ManiphestTransaction();
|
||||||
|
|
||||||
$transactions = array();
|
|
||||||
foreach ($changes as $type => $value) {
|
foreach ($changes as $type => $value) {
|
||||||
$transaction = clone $template;
|
$transaction = clone $template;
|
||||||
$transaction->setTransactionType($type);
|
$transaction->setTransactionType($type);
|
||||||
|
|
|
@ -324,6 +324,18 @@ final class ManiphestBatchEditController extends ManiphestController {
|
||||||
id(new ManiphestTransactionComment())
|
id(new ManiphestTransactionComment())
|
||||||
->setContent($value));
|
->setContent($value));
|
||||||
break;
|
break;
|
||||||
|
case ManiphestTransaction::TYPE_PROJECTS:
|
||||||
|
|
||||||
|
// TODO: Clean this mess up.
|
||||||
|
$project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
|
$xaction
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $project_type)
|
||||||
|
->setNewValue(
|
||||||
|
array(
|
||||||
|
'=' => array_fuse($value),
|
||||||
|
));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$xaction->setNewValue($value);
|
$xaction->setNewValue($value);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -269,6 +269,17 @@ final class ManiphestTaskEditController extends ManiphestController {
|
||||||
if ($type == ManiphestTransaction::TYPE_PROJECT_COLUMN) {
|
if ($type == ManiphestTransaction::TYPE_PROJECT_COLUMN) {
|
||||||
$transaction->setNewValue($value['new']);
|
$transaction->setNewValue($value['new']);
|
||||||
$transaction->setOldValue($value['old']);
|
$transaction->setOldValue($value['old']);
|
||||||
|
} else if ($type == ManiphestTransaction::TYPE_PROJECTS) {
|
||||||
|
// TODO: Gross.
|
||||||
|
$project_type =
|
||||||
|
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
|
$transaction
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $project_type)
|
||||||
|
->setNewValue(
|
||||||
|
array(
|
||||||
|
'=' => array_fuse($value),
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
$transaction->setNewValue($value);
|
$transaction->setNewValue($value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,14 +83,19 @@ final class ManiphestTransactionPreviewController extends ManiphestController {
|
||||||
$value = array();
|
$value = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$phids = $value;
|
$phids = array();
|
||||||
foreach ($task->getProjectPHIDs() as $project_phid) {
|
$value = array_fuse($value);
|
||||||
|
foreach ($value as $project_phid) {
|
||||||
$phids[] = $project_phid;
|
$phids[] = $project_phid;
|
||||||
$value[] = $project_phid;
|
$value[$project_phid] = array('dst' => $project_phid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$transaction->setOldValue($task->getProjectPHIDs());
|
$project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
$transaction->setNewValue($value);
|
$transaction
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $project_type)
|
||||||
|
->setOldValue(array())
|
||||||
|
->setNewValue($value);
|
||||||
break;
|
break;
|
||||||
case ManiphestTransaction::TYPE_STATUS:
|
case ManiphestTransaction::TYPE_STATUS:
|
||||||
$phids = array();
|
$phids = array();
|
||||||
|
|
|
@ -53,7 +53,16 @@ final class ManiphestTransactionSaveController extends ManiphestController {
|
||||||
$projects = array_merge($projects, $task->getProjectPHIDs());
|
$projects = array_merge($projects, $task->getProjectPHIDs());
|
||||||
$projects = array_filter($projects);
|
$projects = array_filter($projects);
|
||||||
$projects = array_unique($projects);
|
$projects = array_unique($projects);
|
||||||
$transaction->setNewValue($projects);
|
|
||||||
|
// TODO: Bleh.
|
||||||
|
$project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
|
$transaction
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $project_type)
|
||||||
|
->setNewValue(
|
||||||
|
array(
|
||||||
|
'+' => array_fuse($projects),
|
||||||
|
));
|
||||||
break;
|
break;
|
||||||
case ManiphestTransaction::TYPE_CCS:
|
case ManiphestTransaction::TYPE_CCS:
|
||||||
// Accumulate the new explicit CCs into the array that we'll add in
|
// Accumulate the new explicit CCs into the array that we'll add in
|
||||||
|
|
|
@ -16,7 +16,6 @@ final class ManiphestTransactionEditor
|
||||||
$types[] = ManiphestTransaction::TYPE_DESCRIPTION;
|
$types[] = ManiphestTransaction::TYPE_DESCRIPTION;
|
||||||
$types[] = ManiphestTransaction::TYPE_OWNER;
|
$types[] = ManiphestTransaction::TYPE_OWNER;
|
||||||
$types[] = ManiphestTransaction::TYPE_CCS;
|
$types[] = ManiphestTransaction::TYPE_CCS;
|
||||||
$types[] = ManiphestTransaction::TYPE_PROJECTS;
|
|
||||||
$types[] = ManiphestTransaction::TYPE_SUBPRIORITY;
|
$types[] = ManiphestTransaction::TYPE_SUBPRIORITY;
|
||||||
$types[] = ManiphestTransaction::TYPE_PROJECT_COLUMN;
|
$types[] = ManiphestTransaction::TYPE_PROJECT_COLUMN;
|
||||||
$types[] = ManiphestTransaction::TYPE_UNBLOCK;
|
$types[] = ManiphestTransaction::TYPE_UNBLOCK;
|
||||||
|
@ -55,8 +54,6 @@ final class ManiphestTransactionEditor
|
||||||
return nonempty($object->getOwnerPHID(), null);
|
return nonempty($object->getOwnerPHID(), null);
|
||||||
case ManiphestTransaction::TYPE_CCS:
|
case ManiphestTransaction::TYPE_CCS:
|
||||||
return array_values(array_unique($object->getCCPHIDs()));
|
return array_values(array_unique($object->getCCPHIDs()));
|
||||||
case ManiphestTransaction::TYPE_PROJECTS:
|
|
||||||
return array_values(array_unique($object->getProjectPHIDs()));
|
|
||||||
case ManiphestTransaction::TYPE_PROJECT_COLUMN:
|
case ManiphestTransaction::TYPE_PROJECT_COLUMN:
|
||||||
// These are pre-populated.
|
// These are pre-populated.
|
||||||
return $xaction->getOldValue();
|
return $xaction->getOldValue();
|
||||||
|
@ -74,7 +71,6 @@ final class ManiphestTransactionEditor
|
||||||
case ManiphestTransaction::TYPE_PRIORITY:
|
case ManiphestTransaction::TYPE_PRIORITY:
|
||||||
return (int)$xaction->getNewValue();
|
return (int)$xaction->getNewValue();
|
||||||
case ManiphestTransaction::TYPE_CCS:
|
case ManiphestTransaction::TYPE_CCS:
|
||||||
case ManiphestTransaction::TYPE_PROJECTS:
|
|
||||||
return array_values(array_unique($xaction->getNewValue()));
|
return array_values(array_unique($xaction->getNewValue()));
|
||||||
case ManiphestTransaction::TYPE_OWNER:
|
case ManiphestTransaction::TYPE_OWNER:
|
||||||
return nonempty($xaction->getNewValue(), null);
|
return nonempty($xaction->getNewValue(), null);
|
||||||
|
@ -97,7 +93,6 @@ final class ManiphestTransactionEditor
|
||||||
$new = $xaction->getNewValue();
|
$new = $xaction->getNewValue();
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case ManiphestTransaction::TYPE_PROJECTS:
|
|
||||||
case ManiphestTransaction::TYPE_CCS:
|
case ManiphestTransaction::TYPE_CCS:
|
||||||
sort($old);
|
sort($old);
|
||||||
sort($new);
|
sort($new);
|
||||||
|
@ -149,11 +144,6 @@ final class ManiphestTransactionEditor
|
||||||
return $object->setOwnerPHID($phid);
|
return $object->setOwnerPHID($phid);
|
||||||
case ManiphestTransaction::TYPE_CCS:
|
case ManiphestTransaction::TYPE_CCS:
|
||||||
return $object->setCCPHIDs($xaction->getNewValue());
|
return $object->setCCPHIDs($xaction->getNewValue());
|
||||||
case ManiphestTransaction::TYPE_PROJECTS:
|
|
||||||
ManiphestTaskProject::updateTaskProjects(
|
|
||||||
$object,
|
|
||||||
$xaction->getNewValue());
|
|
||||||
return $object;
|
|
||||||
case ManiphestTransaction::TYPE_SUBPRIORITY:
|
case ManiphestTransaction::TYPE_SUBPRIORITY:
|
||||||
$data = $xaction->getNewValue();
|
$data = $xaction->getNewValue();
|
||||||
$new_sub = $this->getNextSubpriority(
|
$new_sub = $this->getNextSubpriority(
|
||||||
|
@ -425,15 +415,14 @@ final class ManiphestTransactionEditor
|
||||||
|
|
||||||
$project_phids = $adapter->getProjectPHIDs();
|
$project_phids = $adapter->getProjectPHIDs();
|
||||||
if ($project_phids) {
|
if ($project_phids) {
|
||||||
$existing_projects = $object->getProjectPHIDs();
|
$project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
$new_projects = array_unique(
|
|
||||||
array_merge(
|
|
||||||
$project_phids,
|
|
||||||
$existing_projects));
|
|
||||||
|
|
||||||
$xactions[] = id(new ManiphestTransaction())
|
$xactions[] = id(new ManiphestTransaction())
|
||||||
->setTransactionType(ManiphestTransaction::TYPE_PROJECTS)
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
->setNewValue($new_projects);
|
->setMetadataValue('edge:type', $project_type)
|
||||||
|
->setNewValue(
|
||||||
|
array(
|
||||||
|
'+' => array_fuse($project_phids),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $xactions;
|
return $xactions;
|
||||||
|
@ -450,8 +439,6 @@ final class ManiphestTransactionEditor
|
||||||
ManiphestCapabilityEditPriority::CAPABILITY,
|
ManiphestCapabilityEditPriority::CAPABILITY,
|
||||||
ManiphestTransaction::TYPE_STATUS =>
|
ManiphestTransaction::TYPE_STATUS =>
|
||||||
ManiphestCapabilityEditStatus::CAPABILITY,
|
ManiphestCapabilityEditStatus::CAPABILITY,
|
||||||
ManiphestTransaction::TYPE_PROJECTS =>
|
|
||||||
ManiphestCapabilityEditProjects::CAPABILITY,
|
|
||||||
ManiphestTransaction::TYPE_OWNER =>
|
ManiphestTransaction::TYPE_OWNER =>
|
||||||
ManiphestCapabilityEditAssign::CAPABILITY,
|
ManiphestCapabilityEditAssign::CAPABILITY,
|
||||||
PhabricatorTransactions::TYPE_EDIT_POLICY =>
|
PhabricatorTransactions::TYPE_EDIT_POLICY =>
|
||||||
|
@ -460,8 +447,19 @@ final class ManiphestTransactionEditor
|
||||||
ManiphestCapabilityEditPolicies::CAPABILITY,
|
ManiphestCapabilityEditPolicies::CAPABILITY,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$transaction_type = $xaction->getTransactionType();
|
$transaction_type = $xaction->getTransactionType();
|
||||||
|
|
||||||
|
$app_capability = null;
|
||||||
|
if ($transaction_type == PhabricatorTransactions::TYPE_EDGE) {
|
||||||
|
switch ($xaction->getMetadataValue('edge:type')) {
|
||||||
|
case PhabricatorProjectObjectHasProjectEdgeType::EDGECONST:
|
||||||
|
$app_capability = ManiphestCapabilityEditProjects::CAPABILITY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$app_capability = idx($app_capability_map, $transaction_type);
|
$app_capability = idx($app_capability_map, $transaction_type);
|
||||||
|
}
|
||||||
|
|
||||||
if ($app_capability) {
|
if ($app_capability) {
|
||||||
$app = id(new PhabricatorApplicationQuery())
|
$app = id(new PhabricatorApplicationQuery())
|
||||||
|
|
|
@ -30,8 +30,6 @@ final class PhabricatorManiphestTaskTestDataGenerator
|
||||||
$this->generateTaskPriority();
|
$this->generateTaskPriority();
|
||||||
$changes[ManiphestTransaction::TYPE_CCS] =
|
$changes[ManiphestTransaction::TYPE_CCS] =
|
||||||
$this->getCCPHIDs();
|
$this->getCCPHIDs();
|
||||||
$changes[ManiphestTransaction::TYPE_PROJECTS] =
|
|
||||||
$this->getProjectPHIDs();
|
|
||||||
$transactions = array();
|
$transactions = array();
|
||||||
foreach ($changes as $type => $value) {
|
foreach ($changes as $type => $value) {
|
||||||
$transaction = clone $template;
|
$transaction = clone $template;
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a DAO for the Task -> Project table, which denormalizes the
|
|
||||||
* relationship between tasks and projects into a link table so it can be
|
|
||||||
* efficiently queried. This table is not authoritative; the projectPHIDs field
|
|
||||||
* of ManiphestTask is. The rows in this table are regenerated when transactions
|
|
||||||
* are applied to tasks which affected their associated projects.
|
|
||||||
*/
|
|
||||||
final class ManiphestTaskProject extends ManiphestDAO {
|
|
||||||
|
|
||||||
protected $taskPHID;
|
|
||||||
protected $projectPHID;
|
|
||||||
|
|
||||||
public function getConfiguration() {
|
|
||||||
return array(
|
|
||||||
self::CONFIG_IDS => self::IDS_MANUAL,
|
|
||||||
self::CONFIG_TIMESTAMPS => false,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function updateTaskProjects(
|
|
||||||
ManiphestTask $task,
|
|
||||||
array $new_phids) {
|
|
||||||
|
|
||||||
$edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
|
||||||
|
|
||||||
$old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
||||||
$task->getPHID(),
|
|
||||||
$edge_type);
|
|
||||||
|
|
||||||
$add_phids = array_diff($new_phids, $old_phids);
|
|
||||||
$rem_phids = array_diff($old_phids, $new_phids);
|
|
||||||
|
|
||||||
if (!$add_phids && !$rem_phids) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$editor = new PhabricatorEdgeEditor();
|
|
||||||
foreach ($add_phids as $phid) {
|
|
||||||
$editor->addEdge($task->getPHID(), $edge_type, $phid);
|
|
||||||
}
|
|
||||||
foreach ($rem_phids as $phid) {
|
|
||||||
$editor->remEdge($task->getPHID(), $edge_type, $phid);
|
|
||||||
}
|
|
||||||
$editor->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -788,9 +788,16 @@ final class ManiphestTransaction
|
||||||
case self::TYPE_CCS:
|
case self::TYPE_CCS:
|
||||||
$tags[] = MetaMTANotificationType::TYPE_MANIPHEST_CC;
|
$tags[] = MetaMTANotificationType::TYPE_MANIPHEST_CC;
|
||||||
break;
|
break;
|
||||||
case self::TYPE_PROJECTS:
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
|
switch ($this->getMetadataValue('edge:type')) {
|
||||||
|
case PhabricatorProjectObjectHasProjectEdgeType::EDGECONST:
|
||||||
$tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PROJECTS;
|
$tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PROJECTS;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
$tags[] = MetaMTANotificationType::TYPE_MANIPHEST_OTHER;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case self::TYPE_PRIORITY:
|
case self::TYPE_PRIORITY:
|
||||||
$tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PRIORITY;
|
$tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PRIORITY;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue