mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 04:42:40 +01:00
Soften checks on a very old Maniphest transactionmigration
Summary: Ref T9464. If an ancient transaction doesn't have array values for whatever reason, we fail here. Instead, just recover as gracefully as we can. We may get the transaction "wrong" in some sense, but this only impacts what is rendered in the transaction log. Test Plan: This is nearly a year old and there's no real way to test it. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9464 Differential Revision: https://secure.phabricator.com/D14149
This commit is contained in:
parent
3379904237
commit
99e4472447
1 changed files with 32 additions and 20 deletions
|
@ -9,14 +9,18 @@ $metadata = array(
|
|||
'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
|
||||
);
|
||||
foreach (new LiskMigrationIterator($table) as $txn) {
|
||||
// ManiphestTransaction::TYPE_PROJECTS
|
||||
if ($txn->getTransactionType() == 'projects') {
|
||||
if ($txn->getTransactionType() != 'projects') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$old_value = mig20141222_build_edge_data(
|
||||
$txn->getOldValue(),
|
||||
$txn->getObjectPHID());
|
||||
|
||||
$new_value = mig20141222_build_edge_data(
|
||||
$txn->getNewvalue(),
|
||||
$txn->getNewValue(),
|
||||
$txn->getObjectPHID());
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'UPDATE %T SET '.
|
||||
|
@ -29,21 +33,29 @@ foreach (new LiskMigrationIterator($table) as $txn) {
|
|||
json_encode($metadata),
|
||||
$txn->getID());
|
||||
}
|
||||
}
|
||||
|
||||
echo pht('Done.')."\n";
|
||||
|
||||
function mig20141222_build_edge_data(array $project_phids, $task_phid) {
|
||||
function mig20141222_build_edge_data($project_phids, $task_phid) {
|
||||
$edge_data = array();
|
||||
|
||||
// See T9464. If we didn't get a proper array value out of the transaction,
|
||||
// just return an empty value so we can move forward.
|
||||
if (!is_array($project_phids)) {
|
||||
return $edge_data;
|
||||
}
|
||||
|
||||
foreach ($project_phids as $project_phid) {
|
||||
if (!is_scalar($project_phid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$edge_data[$project_phid] = array(
|
||||
'src' => $task_phid,
|
||||
'type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
|
||||
'dst' => $project_phid,
|
||||
);
|
||||
}
|
||||
|
||||
return $edge_data;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue