[3.5.x-dev] Save Element form w/ uploaded file: Integrity constraint violation
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
I have a frontend entries/save-entry with a file input for an assets field.
Looks like some params aren't getting set in the query, causing a constraint violation.
Same form worked in 3.4.
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
craftcms_local.relations, CONSTRAINTrelations_targetId_fkFOREIGN KEY (targetId) REFERENCESelements(id) ON DELETE CASCADE)
The SQL being executed was: INSERT INTOrelations(fieldId,sourceId,sourceSiteId,targetId,sortOrder,dateCreated,dateUpdated,uid) VALUES (258, 142919, NULL, 0, 1, '2020-07-16 12:52:40', '2020-07-16 12:52:40', 'abec2f08-b3d3-4f51-aa92-971240ebe0fd')
Additional info
- Craft version: craftcms/cms 3.5.x-dev (6d6b8ae)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the frontend entries/save-entry submission with a file input for an assets field on the reported Craft 3.5.x-dev version. Inspect how the submitted parameters become the relations INSERT, especially the targetId value shown as 0. Done means the form saves successfully without the reported foreign-key constraint violation and remains compatible with the stated form behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100