Unexpected update of non-submitted Entry from another Section
stevenjwright opened this issue · 6 comments
Description
When saving an entry from the front-end, an entry with the same title has its sectionId and typeId updated in the entries database table.
Steps to reproduce
- Create an Entry in a Section (
sectionA
), title123-456-789
. - Configure Guest Entries set to only allow guest submissions on 1 section
sectionB
. - The site uses Sprig to post the form via AJAX on page load.
- The form uses
sectionB
'sUID
as a hardcoded value. - The form submits the following data (in addition to the section id and CSRF token):
- A
Url Parameter
ofl
as the new entry'sTitle
. - The
Url Parameter
ofl
as a plain text fieldactiveLicenseKey
. - The User's
Session ID
as a plain text fieldsessionId
.
- Load the page where the auto-submitting form is with a URL Parameter
l=123-456-789
. - Assuming this has now fired the POST request to the system, the unrelated entry in
sectionA
will now not be shown on the entry view in the CMS, and its row in theentries
table of the database has had its originaltypeId
andsectionId
be updated to that of the entry forsectionB
.
Additional info
I should say that when this occurs, there is still a new additional record in the database for the new entry that has been submitted. The new entry in sectionB
is in full working order. If I manually change the typeId
and sectionId
back for the original entry, it sits back in the entries view in the CMS, but with a URI
value that correlates to the new entry in sectionB
.
- Craft version:
Craft Pro 3.4.29.1
- PHP version:
7.3.13
- Database driver & version:
MySQL 5.5.5
- Plugins & versions:
Conditional Fields | 0.0.6
Control Panel Nav | 3.0.12
Craft Commerce | 3.1.12
Digital Products | 2.4.0
Feed Me | 4.2.3
Guest Entries | 2.3.0
Redactor | 2.6.1
Sprig | 1.0.0-beta.9
Stripe for Craft Commerce | 2.3.1.1
Code and a Video of this happening are available if you require 👍
Just to add to this, since posting, I've also noticed that it doesn't seem to matter what entry was created beforehand, it seems to soft delete it anyways.
By that, I mean, I created an a new entry in sectionA
(as per steps above), then afterwards I created an entry in sectionC
, nothing to do with the other sections. I went to the page again and the form fired, this time, it updates the database for the entry from sectionC
, but the one from sectionA
remained intact... this suggests to me that for some reason, it is retrieving and updating a row of the last saved entry, irrespective of the section it belongs to.
@stevenjwright Slightly unrelated but I am trying to use Sprig with the guest plugin and I cant get errors to work. Did you manage to get those working?
@philipboomy I've actually got this to work in the end with Sprig - what's happening for you at the moment, are you getting any errors?
Happy to help how I can 👍
Thanks for replying.
I can get it to post but I cant get it to show any errors if I leave out a field. I wonder if its because of the way Craft assign the new entry variable after submitting.
Did you manage to get that part working?
@philipboomy Oh I see - sorry, read your post early hours so didn't read properly.
I don't actually think I did get it to show any errors for me.
What's your use case? Are you trying to do some field validation or something, or are you needing the errors for debugging? Just trying to think of a workaround for you!
@stevenjwright No worries :) I would like to show errors for validations to the submitter. Might have to write a custom module or not use Sprig. I just dont want to reinvent the wheel now that we got a Guest Entry Plugin.