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

Migrate old task transactions to use new display code

Summary: Ref T6027. This converts the old transaction records to the new format so we don't have to keep legacy code around.

Test Plan: Migrated tasks, browsed around, looked at transaction records, didn't see any issues.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T6027

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

+84
+84
resources/sql/autopatches/20160406.columns.1.php
··· 1 + <?php 2 + 3 + $table = new ManiphestTransaction(); 4 + $conn_w = $table->establishConnection('w'); 5 + 6 + foreach (new LiskMigrationIterator($table) as $xaction) { 7 + $type = $xaction->getTransactionType(); 8 + $id = $xaction->getID(); 9 + 10 + // This is an old ManiphestTransaction::TYPE_COLUMN. It did not do anything 11 + // on its own and was hidden from the UI, so we're just going to remove it. 12 + if ($type == 'column') { 13 + queryfx( 14 + $conn_w, 15 + 'DELETE FROM %T WHERE id = %d', 16 + $table->getTableName(), 17 + $id); 18 + continue; 19 + } 20 + 21 + // This is an old ManiphestTransaction::TYPE_PROJECT_COLUMN. It moved 22 + // tasks between board columns; we're going to replace it with a modern 23 + // PhabricatorTransactions::TYPE_COLUMNS transaction. 24 + if ($type == 'projectcolumn') { 25 + try { 26 + $new = $xaction->getNewValue(); 27 + if (!$new || !is_array($new)) { 28 + continue; 29 + } 30 + 31 + $column_phids = idx($new, 'columnPHIDs'); 32 + if (!is_array($column_phids) || !$column_phids) { 33 + continue; 34 + } 35 + 36 + $column_phid = head($column_phids); 37 + if (!$column_phid) { 38 + continue; 39 + } 40 + 41 + $board_phid = idx($new, 'projectPHID'); 42 + if (!$board_phid) { 43 + continue; 44 + } 45 + 46 + $before_phid = idx($new, 'beforePHID'); 47 + $after_phid = idx($new, 'afterPHID'); 48 + 49 + $old = $xaction->getOldValue(); 50 + if ($old && is_array($old)) { 51 + $from_phids = idx($old, 'columnPHIDs'); 52 + $from_phids = array_values($from_phids); 53 + } else { 54 + $from_phids = array(); 55 + } 56 + 57 + $replacement = array( 58 + 'columnPHID' => $column_phid, 59 + 'boardPHID' => $board_phid, 60 + 'fromColumnPHIDs' => $from_phids, 61 + ); 62 + 63 + if ($before_phid) { 64 + $replacement['beforePHID'] = $before_phid; 65 + } else if ($after_phid) { 66 + $replacement['afterPHID'] = $after_phid; 67 + } 68 + 69 + queryfx( 70 + $conn_w, 71 + 'UPDATE %T SET transactionType = %s, oldValue = %s, newValue = %s 72 + WHERE id = %d', 73 + $table->getTableName(), 74 + PhabricatorTransactions::TYPE_COLUMNS, 75 + 'null', 76 + phutil_json_encode(array($replacement)), 77 + $id); 78 + } catch (Exception $ex) { 79 + // If anything went awry, just move on. 80 + } 81 + } 82 + 83 + 84 + }