Details
-
Type:
Bug
-
Status: Done/Fixed
-
Priority:
Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 2.0
-
Fix Version/s: 2.1.2
-
Component/s: CiviContribute
-
Labels:None
Description
v2.0.3
I created a custom data group with 2 checkbox fields, added that to a custom profile, and then added the profile to a contribution page. The first time someone donates everything works fine, but on subsequent donations a Duplicate Key error is thrown because rather than updating the existing custom data, CiviContribute attempts to add a new row to the custom data table, a row that violates a key restriction.
For version 2.0.3, I believe the problem is solved via the attached patch. On line 1694 of ./CRM/Contact/BAO/Contact.php the function CRM_Core_BAO_CustomField::formatCustomField is called with only 5 parameters. The function will take many, but the last one, $entityId, is not being passed and so the function is unable to retrieve the existing record for the custom data associated with that $entityId. This will later cause CiviContribute to try to insert a new row of custom data instead of updating the existing row. NOTE: this only affects checkbox custom data, non-checkbox custom data is handled correctly.
The fix is to pass $contactDetails['contact_id'] as the 6th argument and this appears to resolve the problem. I looked at the same file (Contact.php) in trunk and it would appear to have the same problem, so I assume this is also an issue for 2.1, though I haven't marked it so on this issue.