Skip to content

Commit

Permalink
Fix #1002: If an existing person has already been matched by a previo…
Browse files Browse the repository at this point in the history
…us row, combine import data from the various import rows rather than discarding everything other than the latest row's data.
  • Loading branch information
tbar0970 committed Jan 25, 2024
1 parent 18d7749 commit 1262dbf
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions views/view_10_admin__7_import.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,18 @@ private function _preparePreview()
}

if (!$this->_haveErrors($i)) {
$this->_sess['person_updates'][$existingPerson->id] = $person_row;
if (isset($this->_sess['person_updates'][$existingPerson->id])) {
// a previous import row also matched this same person.
// that can be deliberate.
// Don't overwrite stuff.
$already_groups = array_get($this->_sess['person_updates'][$existingPerson->id], '_groups', Array());
$this->_pushIntoArray($this->_sess['person_updates'][$existingPerson->id], $person_row);
$this->_sess['person_updates'][$existingPerson->id] = $person_row;
$this->_sess['person_updates'][$existingPerson->id]['_groups'] = array_unique(array_merge($already_groups, $person_row['_groups']));

} else {
$this->_sess['person_updates'][$existingPerson->id] = $person_row;
}
$this->_sess['family_updates'][$existingPerson->getValue('familyid')] = $current_existing_family_data;
}
} else {
Expand Down Expand Up @@ -913,7 +924,7 @@ private function _arrayDiffAssoc($x, $y)

private function _pushIntoArray($from, &$to) {
foreach ($from as $k => $v) {
if (strlen($v) && array_key_exists($k, $to) && !strlen($to[$k])) {
if (is_string($v) && strlen($v) && array_key_exists($k, $to) && !strlen($to[$k])) {
// $to has this element but it's empty
$to[$k] = $v;
}
Expand Down

0 comments on commit 1262dbf

Please sign in to comment.