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

Maniphest - kill TYPE_PROJECTS

Summary: Fixes T5245. Migrate old TYPE_PROJECTS transaction to new style edge transactions. Kill remaining rendering code.

Test Plan:
issued some fun queries to get some old-style transaction in my install:

```
// go from nothing to 1
INSERT INTO maniphest_transaction (phid, authorPHID, objectPHID, viewPolicy, editPolicy, commentVersion, transactionType, oldValue, newValue, contentSource, metadata, dateCreated, dateModified)
VALUES ('PHID-XACT-TASK-000000000000000', 'PHID-USER-zo35vxnoi4bxqak6yqhc', 'PHID-TASK-hb5wphctibxxqryo6ssi', 'users', 'users', 0, 'projects', '[]', '["PHID-PROJ-4teaxbjk5okv7mdz2qlx"]', '', '{}', 1419274578, 1419274578)

// go from 1 to 2
INSERT INTO maniphest_transaction (phid, authorPHID, objectPHID, viewPolicy, editPolicy, commentVersion, transactionType, oldValue, newValue, contentSource, metadata, dateCreated, dateModified)
VALUES ('PHID-XACT-TASK-111111111111111', 'PHID-USER-zo35vxnoi4bxqak6yqhc', 'PHID-TASK-hb5wphctibxxqryo6ssi', 'users', 'users', 0, 'projects', '["PHID-PROJ-4teaxbjk5okv7mdz2qlx"]', '["PHID-PROJ-4teaxbjk5okv7mdz2qlx", "PHID-PROJ-a7giqlyyfirqswg6gn6x"]', '', '{}', 1419274580, 1419274580)

// swap 1 for 1 with 2 in set
INSERT INTO maniphest_transaction (phid, authorPHID, objectPHID, viewPolicy, editPolicy, commentVersion, transactionType, oldValue, newValue, contentSource, metadata, dateCreated, dateModified)
VALUES ('PHID-XACT-TASK-222222222222222', 'PHID-USER-zo35vxnoi4bxqak6yqhc', 'PHID-TASK-hb5wphctibxxqryo6ssi', 'users', 'users', 0, 'projects', '["PHID-PROJ-4teaxbjk5okv7mdz2qlx", "PHID-PROJ-a7giqlyyfirqswg6gn6x"]', '["PHID-PROJ-4teaxbjk5okv7mdz2qlx", "PHID-PROJ-cety4gr55gpxzhwtrkhx"]', '', '{}', 1419274582, 1419274582)

// go from 2 to 1
INSERT INTO maniphest_transaction (phid, authorPHID, objectPHID, viewPolicy, editPolicy, commentVersion, transactionType, oldValue, newValue, contentSource, metadata, dateCreated, dateModified)
VALUES ('PHID-XACT-TASK-333333333333333', 'PHID-USER-zo35vxnoi4bxqak6yqhc', 'PHID-TASK-hb5wphctibxxqryo6ssi', 'users', 'users', 0, 'projects', '["PHID-PROJ-4teaxbjk5okv7mdz2qlx", "PHID-PROJ-cety4gr55gpxzhwtrkhx"]', '["PHID-PROJ-4teaxbjk5okv7mdz2qlx"]', '', '{}', 1419274584, 1419274584)
```

took a screenshot. ran the migration script and compared the screenshots and things looked correctly migrated...!

old style:

{F255408}

new style:

{F255407}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T5245

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

+48 -80
+48
resources/sql/autopatches/20141222.maniphestprojtxn.php
··· 1 + <?php 2 + 3 + $table = new ManiphestTransaction(); 4 + $conn_w = $table->establishConnection('w'); 5 + 6 + echo "Converting Maniphest project transactions to modern EDGE ". 7 + "transactions...\n"; 8 + $metadata = array( 9 + 'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,); 10 + foreach (new LiskMigrationIterator($table) as $txn) { 11 + // ManiphestTransaction::TYPE_PROJECTS 12 + if ($txn->getTransactionType() == 'projects') { 13 + $old_value = mig20141222_build_edge_data( 14 + $txn->getOldValue(), 15 + $txn->getObjectPHID()); 16 + $new_value = mig20141222_build_edge_data( 17 + $txn->getNewvalue(), 18 + $txn->getObjectPHID()); 19 + queryfx( 20 + $conn_w, 21 + 'UPDATE %T SET '. 22 + 'transactionType = %s, oldValue = %s, newValue = %s, metaData = %s '. 23 + 'WHERE id = %d', 24 + $table->getTableName(), 25 + PhabricatorTransactions::TYPE_EDGE, 26 + json_encode($old_value), 27 + json_encode($new_value), 28 + json_encode($metadata), 29 + $txn->getID()); 30 + } 31 + } 32 + 33 + echo "Done.\n"; 34 + 35 + function mig20141222_build_edge_data(array $project_phids, $task_phid) { 36 + $edge_data = array(); 37 + foreach ($project_phids as $project_phid) { 38 + if (!is_scalar($project_phid)) { 39 + continue; 40 + } 41 + $edge_data[$project_phid] = array( 42 + 'src' => $task_phid, 43 + 'type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, 44 + 'dst' => $project_phid, 45 + ); 46 + } 47 + return $edge_data; 48 + }
-80
src/applications/maniphest/storage/ManiphestTransaction.php
··· 18 18 // NOTE: this type is deprecated. Keep it around for legacy installs 19 19 // so any transactions render correctly. 20 20 const TYPE_ATTACH = 'attach'; 21 - /** 22 - * TYPE_PROJECTS is legacy and depracted in favor of 23 - * PhabricatorTransactions::TYPE_EDGE; keep it around for legacy 24 - * transaction-rendering. 25 - */ 26 - const TYPE_PROJECTS = 'projects'; 27 21 28 22 const MAILTAG_STATUS = 'maniphest-status'; 29 23 const MAILTAG_OWNER = 'maniphest-owner'; ··· 86 80 if ($old) { 87 81 $phids[] = $old; 88 82 } 89 - break; 90 - case self::TYPE_PROJECTS: 91 - $phids = array_mergev( 92 - array( 93 - $phids, 94 - nonempty($old, array()), 95 - nonempty($new, array()), 96 - )); 97 83 break; 98 84 case self::TYPE_PROJECT_COLUMN: 99 85 $phids[] = $new['projectPHID']; ··· 267 253 return pht('Reassigned'); 268 254 } 269 255 270 - case self::TYPE_PROJECTS: 271 - return pht('Changed Projects'); 272 - 273 256 case self::TYPE_PROJECT_COLUMN: 274 257 return pht('Changed Project Column'); 275 258 ··· 339 322 340 323 case self::TYPE_DESCRIPTION: 341 324 return 'fa-pencil'; 342 - 343 - case self::TYPE_PROJECTS: 344 - return 'fa-briefcase'; 345 325 346 326 case self::TYPE_PROJECT_COLUMN: 347 327 return 'fa-columns'; ··· 483 463 $this->renderHandleLink($new)); 484 464 } 485 465 486 - case self::TYPE_PROJECTS: 487 - $added = array_diff($new, $old); 488 - $removed = array_diff($old, $new); 489 - if ($added && !$removed) { 490 - return pht( 491 - '%s added %d project(s): %s', 492 - $this->renderHandleLink($author_phid), 493 - count($added), 494 - $this->renderHandleList($added)); 495 - } else if ($removed && !$added) { 496 - return pht( 497 - '%s removed %d project(s): %s', 498 - $this->renderHandleLink($author_phid), 499 - count($removed), 500 - $this->renderHandleList($removed)); 501 - } else if ($removed && $added) { 502 - return pht( 503 - '%s changed project(s), added %d: %s; removed %d: %s', 504 - $this->renderHandleLink($author_phid), 505 - count($added), 506 - $this->renderHandleList($added), 507 - count($removed), 508 - $this->renderHandleList($removed)); 509 - } else { 510 - // This is hit when rendering previews. 511 - return pht( 512 - '%s changed projects...', 513 - $this->renderHandleLink($author_phid)); 514 - } 515 - 516 466 case self::TYPE_PRIORITY: 517 467 $old_name = ManiphestTaskPriority::getTaskPriorityName($old); 518 468 $new_name = ManiphestTaskPriority::getTaskPriorityName($new); ··· 730 680 $this->renderHandleLink($new)); 731 681 } 732 682 733 - case self::TYPE_PROJECTS: 734 - $added = array_diff($new, $old); 735 - $removed = array_diff($old, $new); 736 - if ($added && !$removed) { 737 - return pht( 738 - '%s added %d project(s) to %s: %s', 739 - $this->renderHandleLink($author_phid), 740 - count($added), 741 - $this->renderHandleLink($object_phid), 742 - $this->renderHandleList($added)); 743 - } else if ($removed && !$added) { 744 - return pht( 745 - '%s removed %d project(s) from %s: %s', 746 - $this->renderHandleLink($author_phid), 747 - count($removed), 748 - $this->renderHandleLink($object_phid), 749 - $this->renderHandleList($removed)); 750 - } else if ($removed && $added) { 751 - return pht( 752 - '%s changed project(s) of %s, added %d: %s; removed %d: %s', 753 - $this->renderHandleLink($author_phid), 754 - $this->renderHandleLink($object_phid), 755 - count($added), 756 - $this->renderHandleList($added), 757 - count($removed), 758 - $this->renderHandleList($removed)); 759 - } 760 - 761 683 case self::TYPE_PRIORITY: 762 684 $old_name = ManiphestTaskPriority::getTaskPriorityName($old); 763 685 $new_name = ManiphestTaskPriority::getTaskPriorityName($new); ··· 917 839 return pht('The task already has the selected status.'); 918 840 case self::TYPE_OWNER: 919 841 return pht('The task already has the selected owner.'); 920 - case self::TYPE_PROJECTS: 921 - return pht('The task is already associated with those projects.'); 922 842 case self::TYPE_PRIORITY: 923 843 return pht('The task already has the selected priority.'); 924 844 }