Details
-
Type: Patch
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 2.2.6
-
Fix Version/s: 3.0
-
Component/s: CiviCRM API
-
Labels:None
Description
A couple of problems with civicrm_location_update / civicrm_location_add - it does not detect empty addresses and the is_billing field does not update.
1. The API function calls _civicrm_location_update / _civicrm_location_add which sets contact_id value which causes the dataExists function in CRM/Core/BAO/Address.php to always return true even when all other fields are empty.
2. The is_billing field should also not affect the result of dataExists function
3. The is_billing field is not handled in _civicrm_location_update / _civicrm_location_add but is_primary is handled
FIX.
In CRM/Core/BAO/Address.php line 284, change:
if ( in_array ($name, array ('is_primary', 'location_type_id', 'id' ) ) ) {
to
if ( in_array ($name, array ('is_primary', 'location_type_id', 'id', 'contact_id', 'is_billing' ) ) ) {
In api/v2/Location.php:
In function _civicrm_location_add, after $loc['is_primary'] ... insert same thing but for is_billing
In function _civicrm_location_update, after $loc['is_primary'] ... insert same thing but for is_billing
and after if (array_key_exists('is_primary', $params)) ... insert same thing but for is_billing