Problem/Motivation
When trying to send remidner emails via the ScheduleEmailWebormHandler the email would not get send and the following error would be loggeded Email not sent for Scheduled email handler because a To, CC, or BCC email was not provided
That's because in \Drupal\webform\Entity\Webform::initElementsTranslation we check if the webform's language is the same as current language and if it is, translations are not initiated, which results in an empty element type value and \Drupal\webform\Plugin\WebformElementManager::invokeMethod then skips sending.
Steps to reproduce
- Multilingual site, default language German, additional language French.
- Create a webform that has an email field.
- Create an email handler that uses the schedule email handler. Use the email field as To. Set the Send on to something testable (Current date, Custom date,...)
- Translate the form to French.
- Create a test submission using the French translation
- Run
drush webform:scheduled-email:cron
This should result in the mentioned error and no emails sent.
Proposed resolution
Change how current language is fetched.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | webform-translation-not-loaded-3385893-2.patch | 562 bytes | primsi |
Comments
Comment #2
primsi commentedInitial patch with solution proposed by @Berdir.
Comment #3
berdirThis is not about drush, it's about code that changes the config override language like for example \Drupal\webform_scheduled_email\WebformScheduledEmailManager::cronSend() does.
Comment #4
jrockowitz commentedComment #5
jrockowitz commented