Contribution page profile for honoree (db error)
Hi there, we're getting a database error originating from how the profile is used in the honoree section of a contribution page.
No profile is selected here in our admin, so it appears to be using the "Honoree individual" reserved profile, which includes some contact/individual fields. To this we've added a new field that is a custom field on the Contribution object (more specifically we created this field on the contribution so the end user could enter notes relating to why they are honoring this person, so that you have an idea of the use case).
With this configuration, when a user fills out the contribution page with an honoree and enters text in this field, the contribution fails with a database error. This is shown in the Civi log:
[message] => DB Error: constraint violation
[debug_info] => INSERT INTO civicrm_value_honoree_infor_17 ( note_53
,entity_id
) VALUES ( 'my note text',32747 ) ON DUPLICATE KEY UPDATE note_53 = 'my note text' [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (db_name
.civicrm_value_honoree_infor_17
, CONSTRAINT FK_civicrm_value_honoree_infor_17_entity_id
FOREIGN KEY (entity_id
) REFERENCES civicrm_contribution
(id
) ON DELETE CASCADE)]
What appears to be happening is that the entity_id that's being passed through to create the custom field value is that for a contact, rather than the contribution's id. In this case 32747 is the ID for a contact that was attempting to be created, not a contribution.