Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.3.5
-
Fix Version/s: 4.4.4
-
Component/s: Core CiviCRM
-
Labels:None
Description
I have written a simplified front end for contact data entry in our church. Everything was working well until I updated civicrm to 4.3.5 from 4.2.6. Now, my frontend code generates multiple distinct phone number entries.
Currently, I'm assembling household data, contact data, and location data in one large array using api chaining syntax. I send all the data using the civicrm_api() wrapper. I combine it all so that there are fewer server hits, and because I want to trust the api to do it's job.
However, chaining always seemed to create duplicates with activities and certain custom fields, so I separated them out. Now, however, it's creating MANY duplicates of the phone records. Here's some sample data just before calling civicrm_api(). Note that the Household exists in the database already (it has a contact id) as does the Individual (also has a contact id), but in this case, the Individual Home Phone number is new:
[code]
Array
(
[contact_id] => 8481
[household_name] => Household 1
[contact_type] => Household
[api.phone.create] => Array
(
[0] => Array
(
[phone] => 111-111-1111
[id] => 4705
[location_type_id] => 1
[phone_type_id] => 1
[contact_id] => 8481
)
[1] => Array
(
[phone] => 222-222-2222
[id] => 4706
[location_type_id] => 1
[phone_type_id] => 2
[contact_id] => 8481
)
)
[api.email.create] => Array
(
[0] => Array
(
[email] => a@b.c
[id] => 3663
[location_type_id] => 1
[contact_id] => 8481
)
)
[api.contact.create] => Array
(
[0] => Array
(
[contact_type] => Individual
[first_name] => Person
[last_name] => Household 1
[contact_id] => 8482
[api.phone.create] => Array
(
[0] => Array
(
[phone] => 333-333-3333
[location_type_id] => 1
[phone_type_id] => 1
[contact_id] => 8482
[is_primary] => 1
)
)
[api.note.create] => Array
(
[entity_table] => civicrm_contact
[note] => MODIFIED WITH API ON Tue, 20 Aug 2013 15:43:55 -0400
[entity_id] => 8482
[contact_id] => 1
[subject] => API NOTE
)
[api.relationship.create] => Array
(
[contact_id_a] => 8482
[contact_id_b] => 8481
[relationship_type_id] => 7
[is_active] => 1
[is_permission_a_b] => 0
[is_permission_b_a] => 1
[id] => 3207
)
)
)
[version] => 3
)
[/code]
Then immediately after calling civicrm_api() with this array, I get the following response:
[code]
Array
(
[is_error] => 0
[version] => 3
[count] => 1
[id] => 8481
[values] => Array
(
[8481] => Array
(
[id] => 8481
[contact_type] => Household
[contact_sub_type] =>
[do_not_email] => 0
[do_not_phone] => 0
[do_not_mail] => 0
[do_not_sms] => 0
[do_not_trade] => 0
[is_opt_out] => 0
[legal_identifier] =>
[external_identifier] =>
[sort_name] => Household 1
[display_name] => Household 1
[nick_name] =>
[legal_name] =>
[image_URL] =>
[preferred_communication_method] =>
[preferred_language] => en_US
[preferred_mail_format] => Both
[hash] => e5fedf6202b5f0aefe8497b28150ab23
[api_key] =>
[first_name] =>
[middle_name] =>
[last_name] =>
[prefix_id] =>
[suffix_id] =>
[email_greeting_id] => 5
[email_greeting_custom] =>
[email_greeting_display] => Dear Household 1
[postal_greeting_id] => 5
[postal_greeting_custom] =>
[postal_greeting_display] => Dear Household 1
[addressee_id] => 2
[addressee_custom] =>
[addressee_display] => Household 1
[job_title] =>
[gender_id] =>
[birth_date] =>
[is_deceased] => 0
[deceased_date] =>
[household_name] => Household 1
[primary_contact_id] =>
[organization_name] =>
[sic_code] =>
[user_unique_id] =>
[created_date] => 2013-08-20 15:43:01
[modified_date] => 2013-08-20 15:43:02
[api.phone.create] => Array
(
[0] => Array
(
[is_error] => 0
[undefined_fields] => Array
(
[0] => entity_id
[1] => entity_table
[2] => contact_id
[3] => api.has_parent
[4] => phone
[5] => id
[6] => location_type_id
[7] => phone_type_id
)
[version] => 3
[count] => 1
[id] => 4705
[values] => Array
(
[0] => Array
(
[id] => 4705
[contact_id] => 8481
[location_type_id] => 1
[is_primary] =>
[is_billing] =>
[mobile_provider_id] =>
[phone] => 111-111-1111
[phone_ext] =>
[phone_numeric] =>
[phone_type_id] => 1
)
)
)
[1] => Array
(
[is_error] => 0
[undefined_fields] => Array
(
[0] => entity_id
[1] => entity_table
[2] => contact_id
[3] => api.has_parent
[4] => phone
[5] => id
[6] => location_type_id
[7] => phone_type_id
)
[version] => 3
[count] => 1
[id] => 4706
[values] => Array
(
[0] => Array
(
[id] => 4706
[contact_id] => 8481
[location_type_id] => 1
[is_primary] =>
[is_billing] =>
[mobile_provider_id] =>
[phone] => 222-222-2222
[phone_ext] =>
[phone_numeric] =>
[phone_type_id] => 2
)
)
)
)
[api.email.create] => Array
(
[0] => Array
(
[is_error] => 0
[undefined_fields] => Array
(
[0] => entity_id
[1] => entity_table
[2] => 1_id
[3] => api.has_parent
[4] => email
[5] => id
[6] => location_type_id
[7] => contact_id
)
[version] => 3
[count] => 1
[id] => 3663
[values] => Array
(
[0] => Array
(
[id] => 3663
[contact_id] => 8481
[location_type_id] => 1
[email] => a@b.c
[is_primary] =>
[is_billing] =>
[on_hold] =>
[is_bulkmail] =>
[hold_date] =>
[reset_date] =>
[signature_text] =>
[signature_html] =>
)
)
)
)
[api.contact.create] => Array
(
[0] => Array
(
[is_error] => 0
[undefined_fields] => Array
(
[0] => api.has_parent
[1] => contact_type
[2] => first_name
[3] => last_name
[4] => api.phone.create
[5] => api.note.create
[6] => api.relationship.create
[7] => id
[8] => contact_sub_type
)
[version] => 3
[count] => 1
[id] => 8482
[values] => Array
(
[0] => Array
(
[id] => 8482
[contact_type] => Individual
[contact_sub_type] =>
[do_not_email] => 0
[do_not_phone] => 0
[do_not_mail] => 0
[do_not_sms] => 0
[do_not_trade] => 0
[is_opt_out] => 0
[legal_identifier] =>
[external_identifier] =>
[sort_name] => Household 1, Person
[display_name] => Person Household 1
[nick_name] =>
[legal_name] =>
[image_URL] =>
[preferred_communication_method] =>
[preferred_language] => en_US
[preferred_mail_format] => Both
[hash] => 07b9ccbc5c20771fe4c871852cc60d7f
[api_key] =>
[first_name] => Person
[middle_name] =>
[last_name] => Household 1
[prefix_id] =>
[suffix_id] =>
[email_greeting_id] => 1
[email_greeting_custom] =>
[email_greeting_display] => Dear Person
[postal_greeting_id] => 1
[postal_greeting_custom] =>
[postal_greeting_display] => Dear Person
[addressee_id] => 1
[addressee_custom] =>
[addressee_display] => Person Household 1
[job_title] =>
[gender_id] =>
[birth_date] =>
[is_deceased] => 0
[deceased_date] =>
[household_name] =>
[primary_contact_id] =>
[organization_name] =>
[sic_code] =>
[user_unique_id] =>
[created_date] => 2013-08-20 15:43:02
[modified_date] => 2013-08-20 15:43:02
[api.note.create] => Array
(
[is_error] => 0
[undefined_fields] => Array
(
[0] => entity_table
[1] => modified_date
[2] => entity_id
[3] => 0_id
[4] => api.has_parent
[5] => note
[6] => contact_id
[7] => subject
[8] => privacy
)
[version] => 3
[count] => 1
[id] => 21399
[values] => Array
(
[0] => Array
(
[id] => 21399
[entity_table] => civicrm_contact
[entity_id] => 8482
[note] => MODIFIED WITH API ON Tue, 20 Aug 2013 15:43:55 -0400
[contact_id] => 1
[modified_date] => 20130820154358
[subject] => API NOTE
[privacy] => 0
)
)
)
[api.relationship.create] => Array
(
[is_error] => 0
[version] => 3
[count] => 1
[id] => 3207
[values] => Array
(
[3207] => Array
(
[id] => 3207
[moreIDs] => 3207
)
)
)
)
[8482] => Array
(
[api.phone.create] => Array
(
[0] => Array
(
[is_error] => 0
[undefined_fields] => Array
(
[0] => is_primary
[1] => entity_id
[2] => entity_table
[3] => contact_id
[4] => api.has_parent
[5] => phone
[6] => location_type_id
[7] => phone_type_id
)
[version] => 3
[count] => 1
[id] => 4785
[values] => Array
(
[0] => Array
(
[id] => 4785
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 1
[is_billing] =>
[mobile_provider_id] =>
[phone] => 333-333-3333
[phone_ext] =>
[phone_numeric] =>
[phone_type_id] => 1
)
)
)
)
[api.note.create] => Array
(
[is_error] => 0
[undefined_fields] => Array
(
[0] => entity_table
[1] => modified_date
[2] => entity_id
[3] => 0_id
[4] => api.has_parent
[5] => note
[6] => contact_id
[7] => subject
[8] => privacy
)
[version] => 3
[count] => 1
[id] => 21400
[values] => Array
(
[0] => Array
(
[id] => 21400
[entity_table] => civicrm_contact
[entity_id] => 8482
[note] => MODIFIED WITH API ON Tue, 20 Aug 2013 15:43:55 -0400
[contact_id] => 1
[modified_date] => 20130820154358
[subject] => API NOTE
[privacy] => 0
)
)
)
[api.relationship.create] => Array
(
[is_error] => 0
[version] => 3
[count] => 1
[id] => 3207
[values] => Array
(
[3207] => Array
(
[id] => 3207
[moreIDs] => 3207
)
)
)
)
)
)
)
)
)
)
[/code]
Everything looks good right?
Well, if I do a Contact get, civicrm returns this data:
[code]
Array
(
[contacts] => Array
(
[8482] => Array
(
[contact_id] => 8482
[contact_type] => Individual
[display_name] => Person Household 1
[first_name] => Person
[last_name] => Household 1
[birth_date] =>
[household_name] =>
[contact_is_deleted] => 0
[civicrm_value_custom_contact_fields_1_id] => 5544
[custom_1] =>
[custom_2] => Visitor (First Time)
[custom_3] => 2013-08-18 12:00:00
[custom_6] =>
[custom_7] =>
[custom_20] =>
[custom_21] =>
[custom_22] =>
[civicrm_value_communication_card_decisions__am_3_id] =>
[custom_17] =>
[custom_19] =>
[civicrm_value_photos__amp_files_4_id] =>
[custom_18] =>
[id] => 8482
[location] => Array
(
[emails] => Array
(
[by_index] => Array
(
)
[home] => Array
(
)
[work] => Array
(
)
)
[phones] => Array
(
[by_index] => Array
(
[4707] => Array
(
[id] => 4707
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4708] => Array
(
[id] => 4708
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4709] => Array
(
[id] => 4709
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4710] => Array
(
[id] => 4710
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4711] => Array
(
[id] => 4711
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4712] => Array
(
[id] => 4712
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4713] => Array
(
[id] => 4713
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4714] => Array
(
[id] => 4714
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4715] => Array
(
[id] => 4715
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4716] => Array
(
[id] => 4716
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4717] => Array
(
[id] => 4717
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4718] => Array
(
[id] => 4718
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4719] => Array
(
[id] => 4719
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4720] => Array
(
[id] => 4720
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4721] => Array
(
[id] => 4721
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4722] => Array
(
[id] => 4722
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4723] => Array
(
[id] => 4723
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4724] => Array
(
[id] => 4724
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4725] => Array
(
[id] => 4725
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4726] => Array
(
[id] => 4726
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4727] => Array
(
[id] => 4727
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4728] => Array
(
[id] => 4728
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4729] => Array
(
[id] => 4729
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4730] => Array
(
[id] => 4730
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
[4731] => Array
(
[id] => 4731
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
)
[home] => Array
(
[mobile] => Array
(
)
[phone] => Array
(
[id] => 4731
[contact_id] => 8482
[location_type_id] => 1
[is_primary] => 0
[is_billing] => 0
[phone] => 333-333-3333
[phone_numeric] => 3333333333
[phone_type_id] => 1
[location] => Home
[type] => Phone
)
)
[work] => Array
(
[mobile] => Array
(
)
[phone] => Array
(
)
)
)
[addresses] => Array
(
[by_index] => Array
(
)
[home] => Array
(
)
[work] => Array
(
)
)
)
[photo] => Array
(
)
)
)
)
[/code]
Notice the 25 Phone number entries.