3 edited tags
| link
2 edited tags
| link
1
source | link

DeDupe errors when Individuals have Membership (by relationship)

I have borrowed the title from this unanswered forum post by Laryn: DeDupe errors when Individuals have Membership (by relationship).

Just encountered the same error on a Civi 4.6.9 / Drupal 7 site. Laryn, did you get anywhere with this? Or can anyone shed any light? It appears that CRM_Member_BAO_Membership::createRelatedMemberships(), via some intermediate function calls, tried to insert a civicrm_membership record without specifying membership_type_id: our error & backtrace is very similar to Laryn's:

[debug_info] => INSERT INTO civicrm_membership (contact_id , status_id , owner_membership_id ) VALUES ( 15835 , 2 , 21422 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (my_civicrm.civicrm_membership, CONSTRAINT FK_civicrm_membership_membership_type_id FOREIGN KEY (membership_type_id) REFERENCES civicrm_membership_type (id) ON DELETE CASCA)]

Excerpt from backtrace:

#10 .../civicrm/packages/DB/DataObject.php(1060): DB_DataObject->_query("INSERT INTO civicrm_membership (contact_id , status_id , owner_membership_id ...")
#11 .../civicrm/CRM/Core/DAO.php(450): DB_DataObject->insert()
#12 .../civicrm/CRM/Member/BAO/Membership.php(102): CRM_Core_DAO->save()
#13 .../civicrm/CRM/Member/BAO/Membership.php(310): CRM_Member_BAO_Membership::add((Array:6), (Array:0))
#14 .../civicrm/CRM/Member/BAO/Membership.php(1941): CRM_Member_BAO_Membership::create((Array:6), (Array:0))
#15 .../civicrm/CRM/Dedupe/Merger.php(1655): CRM_Member_BAO_Membership::createRelatedMemberships((Array:4), Object(CRM_Member_DAO_Membership))
#16 .../civicrm/CRM/Dedupe/Merger.php(512): CRM_Dedupe_Merger::addMembershipToRealtedContacts(6428)
#17 .../civicrm/CRM/Dedupe/Merger.php(1349): CRM_Dedupe_Merger::moveContactBelongings("6428", "36044")
#18 .../civicrm/CRM/Dedupe/Merger.php(660): CRM_Dedupe_Merger::moveAllBelongings("6428", "36044", (Array:6))
#19 .../civicrm/CRM/Dedupe/Merger.php(596): CRM_Dedupe_Merger::merge((Array:75), (Array:3), "safe", TRUE, TRUE)
#20 .../civicrm/CRM/Contact/Page/DedupeFind.php(97): CRM_Dedupe_Merger::batchMerge("11", "48", "safe", TRUE, TRUE)
#21 .../civicrm/CRM/Core/Invoke.php(312): CRM_Contact_Page_DedupeFind->run((Array:3), NULL)