@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<?php
2
3$table = new ManiphestTransaction();
4$conn_w = $table->establishConnection('w');
5
6echo pht(
7 "Converting Maniphest project transactions to modern edge transactions...\n");
8$metadata = array(
9 'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
10);
11foreach (new LiskMigrationIterator($table) as $txn) {
12 if ($txn->getTransactionType() != 'projects') {
13 continue;
14 }
15
16 $old_value = mig20141222_build_edge_data(
17 $txn->getOldValue(),
18 $txn->getObjectPHID());
19
20 $new_value = mig20141222_build_edge_data(
21 $txn->getNewValue(),
22 $txn->getObjectPHID());
23
24 queryfx(
25 $conn_w,
26 'UPDATE %T SET '.
27 'transactionType = %s, oldValue = %s, newValue = %s, metaData = %s '.
28 'WHERE id = %d',
29 $table->getTableName(),
30 PhabricatorTransactions::TYPE_EDGE,
31 json_encode($old_value),
32 json_encode($new_value),
33 json_encode($metadata),
34 $txn->getID());
35}
36
37echo pht('Done.')."\n";
38
39function mig20141222_build_edge_data($project_phids, $task_phid) {
40 $edge_data = array();
41
42 // See T9464. If we didn't get a proper array value out of the transaction,
43 // just return an empty value so we can move forward.
44 if (!is_array($project_phids)) {
45 return $edge_data;
46 }
47
48 foreach ($project_phids as $project_phid) {
49 if (!is_scalar($project_phid)) {
50 continue;
51 }
52
53 $edge_data[$project_phid] = array(
54 'src' => $task_phid,
55 'type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
56 'dst' => $project_phid,
57 );
58 }
59
60 return $edge_data;
61}