mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 12:42:43 +01:00
cd7171ec6e
Summary: Ref T2222. Ref T3886. Differential has a legacy storage table for auxiliary fields; move the data to modern storage. Test Plan: - Ran migration. - Verified fields still worked properly afterward (view, edit, etc). Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3886, T2222 Differential Revision: https://secure.phabricator.com/D8355
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
final class DifferentialAuxiliaryField {
|
|
|
|
public static function loadFromStorage(
|
|
DifferentialRevision $revision,
|
|
array $aux_fields) {
|
|
assert_instances_of($aux_fields, 'DifferentialFieldSpecification');
|
|
|
|
$storage_keys = array_filter(mpull($aux_fields, 'getStorageKey'));
|
|
$field_data = array();
|
|
if ($storage_keys) {
|
|
$index_map = array();
|
|
foreach ($storage_keys as $key) {
|
|
$index_map[PhabricatorHash::digestForIndex($key)] = $key;
|
|
}
|
|
|
|
$index_data = id(new DifferentialCustomFieldStorage())->loadAllWhere(
|
|
'objectPHID = %s AND fieldIndex IN (%Ls)',
|
|
$revision->getPHID(),
|
|
array_keys($index_map));
|
|
$index_data = mpull($index_data, 'getFieldValue', 'getFieldIndex');
|
|
|
|
foreach ($index_data as $index => $data) {
|
|
$field_data[$index_map[$index]] = $data;
|
|
}
|
|
}
|
|
|
|
foreach ($aux_fields as $aux_field) {
|
|
$aux_field->setRevision($revision);
|
|
$key = $aux_field->getStorageKey();
|
|
if ($key) {
|
|
$aux_field->setValueFromStorage(idx($field_data, $key));
|
|
}
|
|
}
|
|
|
|
return $aux_fields;
|
|
}
|
|
|
|
}
|