Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / resources / sql / autopatches / 20140321.mstatus.2.mig.php
blob654ca7881c82d88c137b67eee4f1e1194171d3ad
1 <?php
3 $status_map = array(
4 0 => 'open',
5 1 => 'resolved',
6 2 => 'wontfix',
7 3 => 'invalid',
8 4 => 'duplicate',
9 5 => 'spite',
12 $conn_w = id(new ManiphestTask())->establishConnection('w');
14 echo pht('Migrating tasks to new status constants...')."\n";
15 foreach (new LiskMigrationIterator(new ManiphestTask()) as $task) {
16 $id = $task->getID();
17 echo pht('Migrating %s...', "T{$id}")."\n";
19 $status = $task->getStatus();
20 if (isset($status_map[$status])) {
21 queryfx(
22 $conn_w,
23 'UPDATE %T SET status = %s WHERE id = %d',
24 $task->getTableName(),
25 $status_map[$status],
26 $id);
30 echo pht('Done.')."\n";
33 echo pht('Migrating task transactions to new status constants...')."\n";
34 foreach (new LiskMigrationIterator(new ManiphestTransaction()) as $xaction) {
35 $id = $xaction->getID();
36 echo pht('Migrating %d...', $id)."\n";
38 $xn_type = ManiphestTaskStatusTransaction::TRANSACTIONTYPE;
39 if ($xaction->getTransactionType() == $xn_type) {
40 $old = $xaction->getOldValue();
41 if ($old !== null && isset($status_map[$old])) {
42 $old = $status_map[$old];
45 $new = $xaction->getNewValue();
46 if (isset($status_map[$new])) {
47 $new = $status_map[$new];
50 queryfx(
51 $conn_w,
52 'UPDATE %T SET oldValue = %s, newValue = %s WHERE id = %d',
53 $xaction->getTableName(),
54 json_encode($old),
55 json_encode($new),
56 $id);
59 echo pht('Done.')."\n";
61 $conn_w = id(new PhabricatorSavedQuery())->establishConnection('w');
63 echo pht('Migrating searches to new status constants...')."\n";
64 foreach (new LiskMigrationIterator(new PhabricatorSavedQuery()) as $query) {
65 $id = $query->getID();
66 echo pht('Migrating %d...', $id)."\n";
68 if ($query->getEngineClassName() !== 'ManiphestTaskSearchEngine') {
69 continue;
72 $params = $query->getParameters();
73 $statuses = idx($params, 'statuses', array());
74 if ($statuses) {
75 $changed = false;
76 foreach ($statuses as $key => $status) {
77 if (isset($status_map[$status])) {
78 $statuses[$key] = $status_map[$status];
79 $changed = true;
83 if ($changed) {
84 $params['statuses'] = $statuses;
86 queryfx(
87 $conn_w,
88 'UPDATE %T SET parameters = %s WHERE id = %d',
89 $query->getTableName(),
90 json_encode($params),
91 $id);
95 echo pht('Done.')."\n";