From c4cd80f9800a5830c51cd23583d64bf654de6fa2 Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Wed, 3 May 2023 14:09:53 -0400 Subject: [PATCH] Fixes core#4269 - import 'fill' doesn't work on phone/email --- CRM/Contact/Import/Parser/Contact.php | 2 ++ .../CRM/Contact/Import/Parser/ContactTest.php | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index b9c3f95bdd..868efc3336 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -870,6 +870,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { $contactParams = [ 'contact_id' => $cid, + // core#4269 - Don't check relationships for values. + 'noRelationships' => TRUE, ]; $defaults = []; diff --git a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php index 9f3b2d5475..732d00bbec 100644 --- a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php +++ b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php @@ -368,6 +368,34 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase { } + /** + * Test that importing a phone/email with "Fill" strategy doesn't get related contact info. + * See core#4269. + * + * @throws \Exception + */ + public function testImportFillWithRelatedContact(): void { + $anthony = $this->individualCreate(); + $jon = $this->individualCreate(['first_name' => 'Jon']); + Phone::create() + ->addValue('contact_id', $jon) + ->addValue('location_type_id:label', 'Home') + ->addValue('phone', '123-456-7890') + ->execute(); + Relationship::create(FALSE) + ->addValue('contact_id_a', $anthony) + ->addValue('contact_id_b', $jon) + ->addValue('relationship_type_id', 1) + ->execute(); + + $this->runImport([ + 'id' => $anthony, + 'phone' => '212-555-1212', + ], CRM_Import_Parser::DUPLICATE_FILL, FALSE); + $anthonysPhone = $this->callAPISuccessGetSingle('Phone', ['contact_id' => $anthony]); + $this->assertEquals('212-555-1212', $anthonysPhone['phone']); + } + /** * Test import parser will fallback to external identifier. * -- 2.25.1