From 741beb193f24d8b9f4091227ce57af54a029622c Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 2 Jun 2022 18:07:31 +1200 Subject: [PATCH] Remove code that handled now-changed relationship key Note this code is no longer called by contact import, and the others do not pass in relationship key - so we can remove rather than fix --- CRM/Contact/Import/Parser/Contact.php | 20 +------------------ .../CRM/Contact/Import/Parser/ContactTest.php | 2 +- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index bced9c6e5f..12b08567f3 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -785,24 +785,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { /* check if it's a valid custom field id */ $errors[] = $parser->validateCustomField($customFieldID, $value, $customFields[$customFieldID], $dateType); } - elseif (is_array($params[$key]) && isset($params[$key]["contact_type"]) && in_array(substr($key, -3), ['a_b', 'b_a'], TRUE)) { - //CRM-5125 - //supporting custom data of related contact subtypes - $relation = $key; - if (!empty($relation)) { - [$id, $first, $second] = CRM_Utils_System::explode('_', $relation, 3); - $direction = "contact_sub_type_$second"; - $relationshipType = new CRM_Contact_BAO_RelationshipType(); - $relationshipType->id = $id; - if ($relationshipType->find(TRUE)) { - if (isset($relationshipType->$direction)) { - $params[$key]['contact_sub_type'] = $relationshipType->$direction; - } - } - } - - self::isErrorInCustomData($params[$key], $errorMessage, $csType); - } } if ($errors) { $errorMessage .= ($errorMessage ? '; ' : '') . implode('; ', array_filter($errors)); @@ -2106,7 +2088,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { protected function getInvalidValuesForContact($value, string $prefixString): array { $errors = []; foreach ($value as $contactKey => $contactValue) { - if (!preg_match('/^\d+_[a|b]_[a|b]$/', $contactKey)) { + if ($contactKey !== 'relationship') { $result = $this->getInvalidValues($contactValue, $contactKey, $prefixString); if (!empty($result)) { $errors = array_merge($errors, $result); diff --git a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php index 89917de475..e95682dd0e 100644 --- a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php +++ b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php @@ -1838,7 +1838,7 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase { 'phone_type_id' => 1, ], ], - 'related_contacts' => [ + 'relationship' => [ '5_a_b' => [ 'contact_type' => 'Organization', 'contact_sub_type' => NULL, -- 2.25.1