barrelstrength / sprout

Sprout Marketing Suite modules for Craft CMS applications
https://sprout.barrelstrengthdesign.com
Other
2 stars 6 forks source link

Improve Notification Email Event log messages in the web.log file #147

Open brettburwell opened 4 years ago

brettburwell commented 4 years ago

Description

I recently upgraded a site from Craft 2 to 3, and have bumped into a couple issues with Sprout Forms along the way—most notably the disappearing fields described in barrelstrength/sprout-forms#377.

I "fixed" the disappearing fields issue before seeing your recommendations in that thread—and did it manually by updating the DB to update the fieldLayoutId column of the craft_sproutforms_forms table to point to the correct / corresponding id in the craft_fieldlayouts table.

After doing that everything seems to be working properly again (forms submit successfully on the front end, entries are saved and displayed in the CP, notifications sent).

But, as a sanity check I've been watching the logs to see if there was a deeper issue I might be missing by manually updating the DB (which always feels a bit perilous). I'm seeing the following errors popping up in the logs:

 7698: 2019-12-12 16:54:08 [-][-][-][error][barrelstrength\sproutbaseemail\services\NotificationEmailEvents::handleDynamicEvent] When a form entry is saved (Sprout Forms) event does not validate: {"event":["The Form associated with the saved Form Entry Element does not match any selected Forms."]}
 7699: 2019-12-12 16:54:08 [-][-][-][error][barrelstrength\sproutbaseemail\services\NotificationEmailEvents::handleDynamicEvent] When a form entry is saved (Sprout Forms) event does not validate: {"whenNew":["When New cannot be blank."],"whenUpdated":["When Updated cannot be blank."],"event":["The Form associated with the saved Form Entry Element does not match any selected Forms."]}
 7700: 2019-12-12 16:54:08 [-][-][-][error]

I'm honestly not sure if these started happening before or after the change (sorry, in hindsite I should have double checked sooner). But I'm curious if you know what might be causing this?

And knowing that the forms seem to be functioning properly am I reasonably safe to ignore these errors? Or, even better, is there a way to fix the underlying issue to prevent this from turning up in the logs?

Steps to reproduce

  1. Upgrade site from Craft 2 to 3, and upgrade Sprout Forms along with it. Bump into issue barrelstrength/sprout-forms#377 and manually update DB as described above to repair missing fields.
  2. Test submissions on the front end and look for the errors listed above in Craft's web.log file.

Additional info

BenParizek commented 4 years ago

Hey @brettburwell

Glad you have got things resolved. This latest "error" you are seeing should be labeled "notice" or something like that. It's on my radar to improve on but I haven't had the time to figure out the best way to address it yet.

When you have a Notification Email setup to trigger on a "When a Form Entry is saved" event, the Notification Events get checked each time a form is submitted. If the form being submitted doesn't match an existing Notification Event, that event gets marked as if it has errors and as a result does not validate and does not trigger the notification email. So, the above message probably just suggests that you have multiple forms and when some of them get submitted, your Notification Emails for other forms are not getting triggered, which is likely what you want to be happening.

You can test by clearing your logs, submitting a form that does not match an enabled Notification Email using the "When a Form Entry is saved" event, and see that those messages would appear in the logs. If all your Notification Emails are being sent as expected, things are in good shape. And I'll update this task to track getting the messaging around this improved.

brettburwell commented 4 years ago

Hi @BenParizek. Thanks for the quick and thoughtful reply. That's super helpful.

Those error notices aren't hurting anyone, so I don't mind that they're in there. I just wanted to make sure that form submissions weren't failing silently somewhere that I was somehow missing!

Happy Friday, duder.