Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] minor refactor towards removing complexity. #15594

Merged
merged 3 commits into from
Oct 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 26 additions & 28 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1091,36 +1091,34 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio
// CRM-15681 don't display sub-types in UI
continue;
}
foreach (['main' => $main, 'other' => $other] as $moniker => $contact) {
list($label, $value) = self::getFieldValueAndLabel($field, $contact);
$rows["move_$field"][$moniker] = $label;
if ($moniker == 'other') {
//CRM-14334
if ($value === NULL || $value == '') {
$value = 'null';
}
if ($value === 0 or $value === '0') {
$value = $qfZeroBug;
}
if (is_array($value) && empty($value[1])) {
$value[1] = NULL;
}
$rows["move_$field"]['main'] = self::getFieldValueAndLabel($field, $main)['label'];
$rows["move_$field"]['other'] = self::getFieldValueAndLabel($field, $other)['label'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function getFieldValueAndLabel does not appear to return an indexed array, so I don't think you can access ['label'] from its return values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nevermind I see you changed that in this pr.


// Display a checkbox to migrate, only if the values are different
if ($value != $main[$field]) {
$elements[] = [
'advcheckbox',
"move_$field",
NULL,
NULL,
NULL,
$value,
];
}
$value = self::getFieldValueAndLabel($field, $other)['value'];
//CRM-14334
if ($value === NULL || $value == '') {
$value = 'null';
}
if ($value === 0 or $value === '0') {
$value = $qfZeroBug;
}
if (is_array($value) && empty($value[1])) {
$value[1] = NULL;
}

$migrationInfo["move_$field"] = $value;
}
// Display a checkbox to migrate, only if the values are different
if ($value != $main[$field]) {
$elements[] = [
'advcheckbox',
"move_$field",
NULL,
NULL,
NULL,
$value,
];
}

$migrationInfo["move_$field"] = $value;
$rows["move_$field"]['title'] = $fields[$field]['title'];
}

Expand Down Expand Up @@ -2524,7 +2522,7 @@ private static function getFieldValueAndLabel($field, $contact): array {
elseif ($field == 'current_employer_id' && !empty($value)) {
$label = "$value (" . CRM_Contact_BAO_Contact::displayName($value) . ")";
}
return [$label, $value];
return ['label' => $label, 'value' => $value];
}

/**
Expand Down