From c2c5a22e7fe4ae7eb22b4826071056d63c41c728 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 2 Oct 2020 14:49:50 +1300 Subject: [PATCH] dev/core#2046 Remove extraneous primary handling This builds on https://github.com/civicrm/civicrm-core/pull/18661 and removes extra primary handling We can feel confident this is not needed as we have done a handful of rounds of tidy up & added tests to ensure that for all 4 entities (email, phone, im & openid) potentially created through this function both the create and the delete functions take action to ensure that the contact is left with exactly one primary address at the end of this process --- CRM/Core/BAO/Block.php | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index 10cff14b3f..5b7587e865 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -225,29 +225,6 @@ class CRM_Core_BAO_Block { unset($value['id']); } } - //lets allow to update primary w/ more cleanly. - if (!$resetPrimaryId && !empty($value['is_primary'])) { - $primaryId = TRUE; - if (is_array($blockIds)) { - foreach ($blockIds as $blockId => $blockValue) { - if (!empty($blockValue['is_primary'])) { - $resetPrimaryId = $blockId; - break; - } - } - } - if ($resetPrimaryId) { - $baoString = 'CRM_Core_BAO_' . $blockName; - $block = new $baoString(); - $block->selectAdd(); - $block->selectAdd("id, is_primary"); - $block->id = $resetPrimaryId; - if ($block->find(TRUE)) { - $block->is_primary = FALSE; - $block->save(); - } - } - } } foreach ($params[$blockName] as $count => $value) { @@ -300,12 +277,6 @@ class CRM_Core_BAO_Block { 'location_type_id' => $value['location_type_id'] ?? NULL, ]; - $contactFields['is_primary'] = 0; - if ($isPrimary && !empty($value['is_primary'])) { - $contactFields['is_primary'] = $value['is_primary']; - $isPrimary = FALSE; - } - $contactFields['is_billing'] = 0; if ($isBilling && !empty($value['is_billing'])) { $contactFields['is_billing'] = $value['is_billing']; -- 2.25.1