"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "CRM/Dedupe/Merger.php" between
civicrm-core-5.59.2.tar.gz and civicrm-core-5.59.3.tar.gz

About: CiviCRM is a constituent relationship management system designed to meet the needs of advocacy, non-profit and non-governmental groups.

Merger.php  (civicrm-core-5.59.2):Merger.php  (civicrm-core-5.59.3)
skipping to change at line 12 skipping to change at line 12
/* /*
+--------------------------------------------------------------------+ +--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. | | Copyright CiviCRM LLC. All rights reserved. |
| | | |
| This work is published under the GNU AGPLv3 license with some | | This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license | | permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing | | and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+ +--------------------------------------------------------------------+
*/ */
use Civi\Api4\Contact;
use Civi\Api4\CustomGroup; use Civi\Api4\CustomGroup;
/** /**
* *
* @package CRM * @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing * @copyright CiviCRM LLC https://civicrm.org/licensing
*/ */
class CRM_Dedupe_Merger { class CRM_Dedupe_Merger {
/** /**
skipping to change at line 688 skipping to change at line 689
* @param int $contactID * @param int $contactID
* @param array $params * @param array $params
* *
* @throws \CRM_Core_Exception * @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException * @throws \Civi\API\Exception\UnauthorizedException
*/ */
protected static function updateContact(int $contactID, $params): void { protected static function updateContact(int $contactID, $params): void {
// This parameter causes blank fields to be be emptied out. // This parameter causes blank fields to be be emptied out.
// We can probably remove. // We can probably remove.
$params['updateBlankLocInfo'] = TRUE; $params['updateBlankLocInfo'] = TRUE;
if (empty($params['contact_type']) || ($params['contact_type'] === 'Organiza
tion' && empty($params['organization_name']))) {
// Ensuring this is set addresses https://lab.civicrm.org/dev/core/-/issue
s/4156
// but not that RM_Dedupe_MergerTest::testMergeWithEmployer covers this sc
enario
// so refactoring of this is safe.
$contact = Contact::get(FALSE)->addWhere('id', '=', $contactID)->addSelect
('organization_name', 'contact_type')->execute()->first();
$params['contact_type'] = $contact['contact_type'];
if (empty($params['organization_name']) && $params['contact_type'] === 'Or
ganization') {
$params['organization_name'] = $contact['organization_name'];
}
}
$data = self::formatProfileContactParams($params, $contactID); $data = self::formatProfileContactParams($params, $contactID);
CRM_Contact_BAO_Contact::create($data); CRM_Contact_BAO_Contact::create($data);
} }
/** /**
* Format profile contact parameters. * Format profile contact parameters.
* *
* Note this function has been duplicated from CRM_Contact_BAO_Contact * Note this function has been duplicated from CRM_Contact_BAO_Contact
* in order to allow us to unravel all the work this class * in order to allow us to unravel all the work this class
* does to prepare to call this & create some sanity. Also start to * does to prepare to call this & create some sanity. Also start to
* eliminate a toxic function. * eliminate a toxic function.
skipping to change at line 710 skipping to change at line 722
* @param array $params * @param array $params
* @param int $contactID * @param int $contactID
* *
* @return array * @return array
*/ */
private static function formatProfileContactParams( private static function formatProfileContactParams(
$params, $params,
int $contactID int $contactID
) { ) {
$data = $contactDetails = []; $data = ['contact_type' => $params['contact_type']];
// get the contact details (hier) // get the contact details (hier)
$details = CRM_Contact_BAO_Contact::getHierContactDetails($contactID, []); $details = CRM_Contact_BAO_Contact::getHierContactDetails($contactID, []);
$contactDetails = $details[$contactID]; $contactDetails = $details[$contactID];
$data['contact_type'] = $contactDetails['contact_type'] ?? NULL;
$data['contact_sub_type'] = $contactDetails['contact_sub_type'] ?? NULL; $data['contact_sub_type'] = $contactDetails['contact_sub_type'] ?? NULL;
//fix contact sub type CRM-5125 //fix contact sub type CRM-5125
if (array_key_exists('contact_sub_type', $params) && if (array_key_exists('contact_sub_type', $params) &&
!empty($params['contact_sub_type']) !empty($params['contact_sub_type'])
) { ) {
$data['contact_sub_type'] = CRM_Utils_Array::implodePadded($params['contac t_sub_type']); $data['contact_sub_type'] = CRM_Utils_Array::implodePadded($params['contac t_sub_type']);
} }
elseif (array_key_exists('contact_sub_type_hidden', $params) && elseif (array_key_exists('contact_sub_type_hidden', $params) &&
!empty($params['contact_sub_type_hidden']) !empty($params['contact_sub_type_hidden'])
skipping to change at line 996 skipping to change at line 1007
// to avoid update with empty values // to avoid update with empty values
continue; continue;
} }
else { else {
$data[$key] = $value; $data[$key] = $value;
} }
} }
} }
} }
if (!isset($data['contact_type'])) {
$data['contact_type'] = 'Individual';
}
return $data; return $data;
} }
/** /**
* Get the relevant location entity for the array key. * Get the relevant location entity for the array key.
* *
* This function is duplicated from CRM_Contact_BAO_Contact to allow cleanup. * This function is duplicated from CRM_Contact_BAO_Contact to allow cleanup.
* See self::formatProfileContactParams * See self::formatProfileContactParams
* *
* Based on the field name we determine which location entity * Based on the field name we determine which location entity
 End of changes. 6 change blocks. 
6 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)