// call the function to sync shared address and create relationships
// if address is already shared, share master_id with all children and update relationships accordingly
// (prevent chaining 2) CRM-21214
- self::processSharedAddress($address->id, $params);
+ self::processSharedAddress($address->id, $params, $hook);
// lets call the post hook only after we've done all the follow on processing
CRM_Utils_Hook::post($hook, 'Address', $address->id, $address);
* Address id.
* @param array $params
* Associated array of address params.
+ * @param string $parentOperation Operation being taken on the parent entity.
*/
- public static function processSharedAddress($addressId, $params) {
+ public static function processSharedAddress($addressId, $params, $parentOperation = NULL) {
$query = 'SELECT id, contact_id FROM civicrm_address WHERE master_id = %1';
$dao = CRM_Core_DAO::executeQuery($query, [1 => [$addressId, 'Integer']]);
$addressDAO->copyValues($params);
$addressDAO->id = $dao->id;
$addressDAO->save();
- $addressDAO->copyCustomFields($addressId, $addressDAO->id);
+ $addressDAO->copyCustomFields($addressId, $addressDAO->id, $parentOperation);
}
}
*
* @param int $entityID
* @param int $newEntityID
+ * @param string $parentOperation
*/
- public function copyCustomFields($entityID, $newEntityID) {
+ public function copyCustomFields($entityID, $newEntityID, $parentOperation = NULL) {
$entity = CRM_Core_DAO_AllCoreTables::getBriefName(get_class($this));
$tableName = CRM_Core_DAO_AllCoreTables::getTableForClass(get_class($this));
// Obtain custom values for the old entity.
}
// Save Custom Fields for new Entity.
- CRM_Core_BAO_CustomValueTable::postProcess($customParams, $tableName, $newEntityID, $entity, 'create');
+ CRM_Core_BAO_CustomValueTable::postProcess($customParams, $tableName, $newEntityID, $entity, $parentOperation ?? 'create');
}
// copy activity attachments ( if any )
$templateContribution = $templateContribution->first();
$this->assertNotNull($templateContribution['template.field']);
$this->assertEquals('Second and most recent Contribution', $templateContribution['template.field']);
+ $this->callAPISuccess('CustomField', 'delete', ['id' => $custom_field['id']]);
+ $this->callAPISuccess('CustomGroup', 'delete', ['id' => $custom_group['id']]);
}
/**