craftcms/guest-entries

JSON error when marking submission as spam

boboldehampsink opened this issue · 7 comments

When marking a submission as spam in an application/json request, the plugin tries to set the (at that point) non-existing author:

'authorUsername' => $entry->getAuthor()->username,

This results in an error

The author should have been assigned from _populateEntryModel() regardless of whether the submission was labeled as spam or not. You’re sure you’re not also getting an error when the submission is not spam?

No in that case it succeeds

Can you step through that _populateEntryModel() code and see why the author isn’t getting set in that case? Or maybe it is, but the plugin that’s marking the submission as spam is clearing it out?

Mmm for some reason it had saved a non-existing uid. When simply saving the guest entries settings again the project.yaml changed and contained a new uid. Now everything works. Thanks anyway!

After that conclusion it started happening to me again. I found that the saved UID is actually from the elements table while the _populateEntryModel() function looks in the users table.

Doh, OK so authors just aren’t ever getting set correctly. Thanks!

This is a duplicate of #43, and fixed in v2.2.3.