Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110081146
20160406.columns.1.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Apr 24, 15:08
Size
2 KB
Mime Type
text/x-php
Expires
Sat, Apr 26, 15:08 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25783385
Attached To
rPH Phabricator
20160406.columns.1.php
View Options
<?php
$table
=
new
ManiphestTransaction
();
$conn_w
=
$table
->
establishConnection
(
'w'
);
foreach
(
new
LiskMigrationIterator
(
$table
)
as
$xaction
)
{
$type
=
$xaction
->
getTransactionType
();
$id
=
$xaction
->
getID
();
// This is an old ManiphestTransaction::TYPE_COLUMN. It did not do anything
// on its own and was hidden from the UI, so we're just going to remove it.
if
(
$type
==
'column'
)
{
queryfx
(
$conn_w
,
'DELETE FROM %T WHERE id = %d'
,
$table
->
getTableName
(),
$id
);
continue
;
}
// This is an old ManiphestTransaction::TYPE_PROJECT_COLUMN. It moved
// tasks between board columns; we're going to replace it with a modern
// PhabricatorTransactions::TYPE_COLUMNS transaction.
if
(
$type
==
'projectcolumn'
)
{
try
{
$new
=
$xaction
->
getNewValue
();
if
(!
$new
||
!
is_array
(
$new
))
{
continue
;
}
$column_phids
=
idx
(
$new
,
'columnPHIDs'
);
if
(!
is_array
(
$column_phids
)
||
!
$column_phids
)
{
continue
;
}
$column_phid
=
head
(
$column_phids
);
if
(!
$column_phid
)
{
continue
;
}
$board_phid
=
idx
(
$new
,
'projectPHID'
);
if
(!
$board_phid
)
{
continue
;
}
$before_phid
=
idx
(
$new
,
'beforePHID'
);
$after_phid
=
idx
(
$new
,
'afterPHID'
);
$old
=
$xaction
->
getOldValue
();
if
(
$old
&&
is_array
(
$old
))
{
$from_phids
=
idx
(
$old
,
'columnPHIDs'
);
$from_phids
=
array_values
(
$from_phids
);
}
else
{
$from_phids
=
array
();
}
$replacement
=
array
(
'columnPHID'
=>
$column_phid
,
'boardPHID'
=>
$board_phid
,
'fromColumnPHIDs'
=>
$from_phids
,
);
if
(
$before_phid
)
{
$replacement
[
'beforePHID'
]
=
$before_phid
;
}
else
if
(
$after_phid
)
{
$replacement
[
'afterPHID'
]
=
$after_phid
;
}
queryfx
(
$conn_w
,
'UPDATE %T SET transactionType = %s, oldValue = %s, newValue = %s
WHERE id = %d'
,
$table
->
getTableName
(),
PhabricatorTransactions
::
TYPE_COLUMNS
,
'null'
,
phutil_json_encode
(
array
(
$replacement
)),
$id
);
}
catch
(
Exception
$ex
)
{
// If anything went awry, just move on.
}
}
}
Event Timeline
Log In to Comment