Skip webform_scheduled_email records when referenced handler cannot be found

Created on 31 January 2025, 2 months ago

Problem/Motivation

We just ran into a repeating PluginNotFoundException in our core cron task after a deleted scheduled email handler somehow left its scheduled email records in webform_scheduled_email. The exception was preventing all other scheduled emails from getting sent, essentially stopping the whole system from functioning.

So far I have been unsuccessful in reproducing the lack of webform_scheduled_email record cleanup in testing scenarios, but I feel compelled to harden the scheduled email handler's cron functionality against this apparently possible situation.

Steps to reproduce

1. Place a record into the webform_scheduled_email table in "send" state with a non-existent handler_id (or somehow reproduce the record cleanup issue described above - resulting in the same).
2. After the record's send date has passed, run core-cron.
3. Watch as a PluginNotFoundException completely blocks the processing of any subsequent records found in the table.

Proposed resolution

Skip and log problematic webform_scheduled_email records rather than derail cron with an exception.

Remaining tasks

MR + review.

User interface changes

None.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Active

Version

6.3

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States chrisolof

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @chrisolof
  • πŸ‡ΊπŸ‡ΈUnited States chrisolof

    Interestingly it seems there is some skipping and cleanup logic already in this submodule.

    The solution cronSchedule seems to take currently (when the referenced webform submission is missing) is to delete the orphaned record from webform_scheduled_email and move on. Cleaning up the orphaned (and unusable) record upon discovery seems better than logging and requiring a site admin to manually clean up the table someday. As such, I'm updating the proposed resolution.

  • Pipeline finished with Failed
    2 months ago
    Total: 463s
    #411637
  • Pipeline finished with Success
    2 months ago
    Total: 838s
    #411645
  • πŸ‡ΊπŸ‡ΈUnited States chrisolof

    MR 595 removes orphaned webform_scheduled_email records when encountered in cron methods instead of trying to proceed with them and causing PluginNotFoundExceptions. This is ready for review.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    This makes sense to me. Can you add a test?

  • Pipeline finished with Success
    2 months ago
    Total: 406s
    #414085
  • πŸ‡ΊπŸ‡ΈUnited States chrisolof

    Thanks Liam. Test coverage added, covering the clean-up of webform_scheduled_email records with missing a plugin or a missing submission, both in schedule and send state (to ensure cleanup is working in cronSchedule() and cronSend()).

    While I was in there I found some disabled test code that seemed disabled due to this orphaned record issue, so I moved, updated, and enabled that check also.

Production build 0.71.5 2024