-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.x]: Saving element in afterSave results in integrity constraint violation exception #15517
Comments
The problem also manifests for me on Craft 4.11.0.2, when using the Adding the This only appeared to start happening after updating to Craft 4.11.0.2 from 4.10.8. Perhaps related to this item in the 4.11.0 changelog:
For reference, my site is not multisite, if that makes any difference. |
@steverowling, thanks for the additional info! We’re looking into it. |
ah thanks @steverowling! I must have been testing an earlier version of 4.x |
@brandonkelly thanks for addressing! Could this fix also be added to 4.x? |
Craft 4.11.2 and 5.3.3 are out with a fix for this! |
What happened?
Description
If you need to (re)-save an element in its
afterSave
, you will get an integrity constraint violation on theelements_sites
table, unless you manually includeisNewForSite = false
.This only happens when trying to save something outside of the normal CP entry form, so it may have something to do with saving directly to a live element vs starting as a draft. Craft 4 has no problem with the same code.
Here's a gist of a contrived example where you want to put the entry ID in the title, so you re-save the entry in the
afterSave
event: https://gist.github.com/timkelty/1cfb09a9611587552ed0f81ab99b1af7Craft CMS version
5.3
Related Issues
https://github.com/craftcms/craftnet/pull/1098
The text was updated successfully, but these errors were encountered: