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

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

+82 -84
-2
src/__phutil_library_map__.php
··· 954 954 'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php', 955 955 'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php', 956 956 'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php', 957 - 'ManiphestTaskProject' => 'applications/maniphest/storage/ManiphestTaskProject.php', 958 957 'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php', 959 958 'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php', 960 959 'ManiphestTaskSearchEngine' => 'applications/maniphest/query/ManiphestTaskSearchEngine.php', ··· 3716 3715 'ManiphestTaskOwner' => 'ManiphestConstants', 3717 3716 'ManiphestTaskPriority' => 'ManiphestConstants', 3718 3717 'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource', 3719 - 'ManiphestTaskProject' => 'ManiphestDAO', 3720 3718 'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3721 3719 'ManiphestTaskResultListView' => 'ManiphestView', 3722 3720 'ManiphestTaskSearchEngine' => 'PhabricatorApplicationSearchEngine',
+11 -2
src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php
··· 116 116 $changes[ManiphestTransaction::TYPE_CCS] = $ccs; 117 117 } 118 118 119 + $transactions = array(); 120 + 119 121 $project_phids = $request->getValue('projectPHIDs'); 120 122 if ($project_phids !== null) { 121 123 $this->validatePHIDList( 122 124 $project_phids, 123 125 PhabricatorProjectPHIDTypeProject::TYPECONST, 124 126 'projectPHIDS'); 125 - $changes[ManiphestTransaction::TYPE_PROJECTS] = $project_phids; 127 + 128 + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 129 + $transactions[] = id(new ManiphestTransaction()) 130 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 131 + ->setMetadataValue('edge:type', $project_type) 132 + ->setNewValue( 133 + array( 134 + '=' => array_fuse($project_phids), 135 + )); 126 136 } 127 137 128 138 $template = new ManiphestTransaction(); 129 139 130 - $transactions = array(); 131 140 foreach ($changes as $type => $value) { 132 141 $transaction = clone $template; 133 142 $transaction->setTransactionType($type);
+12
src/applications/maniphest/controller/ManiphestBatchEditController.php
··· 324 324 id(new ManiphestTransactionComment()) 325 325 ->setContent($value)); 326 326 break; 327 + case ManiphestTransaction::TYPE_PROJECTS: 328 + 329 + // TODO: Clean this mess up. 330 + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 331 + $xaction 332 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 333 + ->setMetadataValue('edge:type', $project_type) 334 + ->setNewValue( 335 + array( 336 + '=' => array_fuse($value), 337 + )); 338 + break; 327 339 default: 328 340 $xaction->setNewValue($value); 329 341 break;
+11
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 269 269 if ($type == ManiphestTransaction::TYPE_PROJECT_COLUMN) { 270 270 $transaction->setNewValue($value['new']); 271 271 $transaction->setOldValue($value['old']); 272 + } else if ($type == ManiphestTransaction::TYPE_PROJECTS) { 273 + // TODO: Gross. 274 + $project_type = 275 + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 276 + $transaction 277 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 278 + ->setMetadataValue('edge:type', $project_type) 279 + ->setNewValue( 280 + array( 281 + '=' => array_fuse($value), 282 + )); 272 283 } else { 273 284 $transaction->setNewValue($value); 274 285 }
+10 -5
src/applications/maniphest/controller/ManiphestTransactionPreviewController.php
··· 83 83 $value = array(); 84 84 } 85 85 86 - $phids = $value; 87 - foreach ($task->getProjectPHIDs() as $project_phid) { 86 + $phids = array(); 87 + $value = array_fuse($value); 88 + foreach ($value as $project_phid) { 88 89 $phids[] = $project_phid; 89 - $value[] = $project_phid; 90 + $value[$project_phid] = array('dst' => $project_phid); 90 91 } 91 92 92 - $transaction->setOldValue($task->getProjectPHIDs()); 93 - $transaction->setNewValue($value); 93 + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 94 + $transaction 95 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 96 + ->setMetadataValue('edge:type', $project_type) 97 + ->setOldValue(array()) 98 + ->setNewValue($value); 94 99 break; 95 100 case ManiphestTransaction::TYPE_STATUS: 96 101 $phids = array();
+10 -1
src/applications/maniphest/controller/ManiphestTransactionSaveController.php
··· 53 53 $projects = array_merge($projects, $task->getProjectPHIDs()); 54 54 $projects = array_filter($projects); 55 55 $projects = array_unique($projects); 56 - $transaction->setNewValue($projects); 56 + 57 + // TODO: Bleh. 58 + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 59 + $transaction 60 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 61 + ->setMetadataValue('edge:type', $project_type) 62 + ->setNewValue( 63 + array( 64 + '+' => array_fuse($projects), 65 + )); 57 66 break; 58 67 case ManiphestTransaction::TYPE_CCS: 59 68 // Accumulate the new explicit CCs into the array that we'll add in
+19 -21
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 16 16 $types[] = ManiphestTransaction::TYPE_DESCRIPTION; 17 17 $types[] = ManiphestTransaction::TYPE_OWNER; 18 18 $types[] = ManiphestTransaction::TYPE_CCS; 19 - $types[] = ManiphestTransaction::TYPE_PROJECTS; 20 19 $types[] = ManiphestTransaction::TYPE_SUBPRIORITY; 21 20 $types[] = ManiphestTransaction::TYPE_PROJECT_COLUMN; 22 21 $types[] = ManiphestTransaction::TYPE_UNBLOCK; ··· 55 54 return nonempty($object->getOwnerPHID(), null); 56 55 case ManiphestTransaction::TYPE_CCS: 57 56 return array_values(array_unique($object->getCCPHIDs())); 58 - case ManiphestTransaction::TYPE_PROJECTS: 59 - return array_values(array_unique($object->getProjectPHIDs())); 60 57 case ManiphestTransaction::TYPE_PROJECT_COLUMN: 61 58 // These are pre-populated. 62 59 return $xaction->getOldValue(); ··· 74 71 case ManiphestTransaction::TYPE_PRIORITY: 75 72 return (int)$xaction->getNewValue(); 76 73 case ManiphestTransaction::TYPE_CCS: 77 - case ManiphestTransaction::TYPE_PROJECTS: 78 74 return array_values(array_unique($xaction->getNewValue())); 79 75 case ManiphestTransaction::TYPE_OWNER: 80 76 return nonempty($xaction->getNewValue(), null); ··· 97 93 $new = $xaction->getNewValue(); 98 94 99 95 switch ($xaction->getTransactionType()) { 100 - case ManiphestTransaction::TYPE_PROJECTS: 101 96 case ManiphestTransaction::TYPE_CCS: 102 97 sort($old); 103 98 sort($new); ··· 149 144 return $object->setOwnerPHID($phid); 150 145 case ManiphestTransaction::TYPE_CCS: 151 146 return $object->setCCPHIDs($xaction->getNewValue()); 152 - case ManiphestTransaction::TYPE_PROJECTS: 153 - ManiphestTaskProject::updateTaskProjects( 154 - $object, 155 - $xaction->getNewValue()); 156 - return $object; 157 147 case ManiphestTransaction::TYPE_SUBPRIORITY: 158 148 $data = $xaction->getNewValue(); 159 149 $new_sub = $this->getNextSubpriority( ··· 425 415 426 416 $project_phids = $adapter->getProjectPHIDs(); 427 417 if ($project_phids) { 428 - $existing_projects = $object->getProjectPHIDs(); 429 - $new_projects = array_unique( 430 - array_merge( 431 - $project_phids, 432 - $existing_projects)); 433 - 418 + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 434 419 $xactions[] = id(new ManiphestTransaction()) 435 - ->setTransactionType(ManiphestTransaction::TYPE_PROJECTS) 436 - ->setNewValue($new_projects); 420 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 421 + ->setMetadataValue('edge:type', $project_type) 422 + ->setNewValue( 423 + array( 424 + '+' => array_fuse($project_phids), 425 + )); 437 426 } 438 427 439 428 return $xactions; ··· 450 439 ManiphestCapabilityEditPriority::CAPABILITY, 451 440 ManiphestTransaction::TYPE_STATUS => 452 441 ManiphestCapabilityEditStatus::CAPABILITY, 453 - ManiphestTransaction::TYPE_PROJECTS => 454 - ManiphestCapabilityEditProjects::CAPABILITY, 455 442 ManiphestTransaction::TYPE_OWNER => 456 443 ManiphestCapabilityEditAssign::CAPABILITY, 457 444 PhabricatorTransactions::TYPE_EDIT_POLICY => ··· 460 447 ManiphestCapabilityEditPolicies::CAPABILITY, 461 448 ); 462 449 450 + 463 451 $transaction_type = $xaction->getTransactionType(); 464 - $app_capability = idx($app_capability_map, $transaction_type); 452 + 453 + $app_capability = null; 454 + if ($transaction_type == PhabricatorTransactions::TYPE_EDGE) { 455 + switch ($xaction->getMetadataValue('edge:type')) { 456 + case PhabricatorProjectObjectHasProjectEdgeType::EDGECONST: 457 + $app_capability = ManiphestCapabilityEditProjects::CAPABILITY; 458 + break; 459 + } 460 + } else { 461 + $app_capability = idx($app_capability_map, $transaction_type); 462 + } 465 463 466 464 if ($app_capability) { 467 465 $app = id(new PhabricatorApplicationQuery())
-2
src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php
··· 30 30 $this->generateTaskPriority(); 31 31 $changes[ManiphestTransaction::TYPE_CCS] = 32 32 $this->getCCPHIDs(); 33 - $changes[ManiphestTransaction::TYPE_PROJECTS] = 34 - $this->getProjectPHIDs(); 35 33 $transactions = array(); 36 34 foreach ($changes as $type => $value) { 37 35 $transaction = clone $template;
-49
src/applications/maniphest/storage/ManiphestTaskProject.php
··· 1 - <?php 2 - 3 - /** 4 - * This is a DAO for the Task -> Project table, which denormalizes the 5 - * relationship between tasks and projects into a link table so it can be 6 - * efficiently queried. This table is not authoritative; the projectPHIDs field 7 - * of ManiphestTask is. The rows in this table are regenerated when transactions 8 - * are applied to tasks which affected their associated projects. 9 - */ 10 - final class ManiphestTaskProject extends ManiphestDAO { 11 - 12 - protected $taskPHID; 13 - protected $projectPHID; 14 - 15 - public function getConfiguration() { 16 - return array( 17 - self::CONFIG_IDS => self::IDS_MANUAL, 18 - self::CONFIG_TIMESTAMPS => false, 19 - ); 20 - } 21 - 22 - public static function updateTaskProjects( 23 - ManiphestTask $task, 24 - array $new_phids) { 25 - 26 - $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 27 - 28 - $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( 29 - $task->getPHID(), 30 - $edge_type); 31 - 32 - $add_phids = array_diff($new_phids, $old_phids); 33 - $rem_phids = array_diff($old_phids, $new_phids); 34 - 35 - if (!$add_phids && !$rem_phids) { 36 - return; 37 - } 38 - 39 - $editor = new PhabricatorEdgeEditor(); 40 - foreach ($add_phids as $phid) { 41 - $editor->addEdge($task->getPHID(), $edge_type, $phid); 42 - } 43 - foreach ($rem_phids as $phid) { 44 - $editor->remEdge($task->getPHID(), $edge_type, $phid); 45 - } 46 - $editor->save(); 47 - } 48 - 49 - }
+9 -2
src/applications/maniphest/storage/ManiphestTransaction.php
··· 788 788 case self::TYPE_CCS: 789 789 $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_CC; 790 790 break; 791 - case self::TYPE_PROJECTS: 792 - $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PROJECTS; 791 + case PhabricatorTransactions::TYPE_EDGE: 792 + switch ($this->getMetadataValue('edge:type')) { 793 + case PhabricatorProjectObjectHasProjectEdgeType::EDGECONST: 794 + $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PROJECTS; 795 + break; 796 + default: 797 + $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_OTHER; 798 + break; 799 + } 793 800 break; 794 801 case self::TYPE_PRIORITY: 795 802 $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PRIORITY;