From c8f7094b1e1098ba95f1704e3ac01f8350e7b351 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 21 Jul 2016 17:33:12 +1200 Subject: [PATCH] CRM-19113 do not lose custom data on merge when permissions in play --- CRM/Contact/BAO/Contact.php | 4 +++- tests/phpunit/api/v3/JobTestCustomDataTest.php | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 4b222079f5..cbc50244aa 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2244,7 +2244,9 @@ ORDER BY civicrm_email.is_primary DESC"; $value, $type, $valueId, - $contactID + $contactID, + FALSE, + FALSE ); } elseif ($key == 'edit') { diff --git a/tests/phpunit/api/v3/JobTestCustomDataTest.php b/tests/phpunit/api/v3/JobTestCustomDataTest.php index 504619d0b5..8b062156aa 100644 --- a/tests/phpunit/api/v3/JobTestCustomDataTest.php +++ b/tests/phpunit/api/v3/JobTestCustomDataTest.php @@ -182,7 +182,7 @@ class api_v3_JobTestCustomDataTest extends CiviUnitTestCase { 'null_merges_with_set_reverse' => array( 'mode' => 'safe', 'contacts' => array( - array('black'), + array('black'), NULL, ), 'skipped' => 0, @@ -363,20 +363,24 @@ class api_v3_JobTestCustomDataTest extends CiviUnitTestCase { /** * Using the api with check perms set to off, make sure custom data is merged. * - * Test CRM-18674 date custom field handling. + * Test CRM-19113 custom data lost when permissions in play. */ public function testBatchMergeIntCustomFieldNoConflictAndNoCheckPerms() { CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM', 'edit my contact'); CRM_Core_DAO::executeQuery("DELETE FROM civicrm_cache"); CRM_Utils_System::flushCache(); $customFieldLabel = 'custom_' . $this->customIntFieldID; - $contactID = $this->individualCreate(); - $this->individualCreate(array($customFieldLabel => 1)); + $contactID = $this->individualCreate(array('custom_' . $this->customBoolFieldID => 1)); + $this->individualCreate(array($customFieldLabel => 1, 'custom_' . $this->customBoolFieldID => 1)); $result = $this->callAPISuccess('Job', 'process_batch_merge', array('check_permissions' => 0)); $this->assertEquals(1, count($result['values']['merged'])); $this->assertEquals(0, count($result['values']['skipped'])); - $contact = $this->callAPISuccess('Contact', 'getsingle', array('id' => $contactID, 'return' => $customFieldLabel)); + $contact = $this->callAPISuccess('Contact', 'getsingle', array( + 'id' => $contactID, + 'return' => array($customFieldLabel, 'custom_' . $this->customBoolFieldID), + )); $this->assertEquals(1, $contact[$customFieldLabel]); + $this->assertEquals(1, $contact['custom_' . $this->customBoolFieldID]); } /** -- 2.25.1