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

  1. Multilingual site, default language German, additional language French.
  2. Create a webform that has an email field.
  3. 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,...)
  4. Translate the form to French.
  5. Create a test submission using the French translation
  6. 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

Comments

Primsi created an issue. See original summary.

primsi’s picture

Status: Active » Needs review
StatusFileSize
new562 bytes

Initial patch with solution proposed by @Berdir.

berdir’s picture

Title: Element translation not loaded when run via drush » Element translation not loaded when changing config override language

This is not about drush, it's about code that changes the config override language like for example \Drupal\webform_scheduled_email\WebformScheduledEmailManager::cronSend() does.

jrockowitz’s picture

Status: Needs review » Reviewed & tested by the community
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

  • Primsi authored 656fd6e6 on 6.1.x
    Issue #3385893 by Primsi: Element translation not loaded when changing...

  • Primsi authored 656fd6e6 on 6.x
    Issue #3385893 by Primsi: Element translation not loaded when changing...

  • Primsi authored 656fd6e6 on 6.2.x
    Issue #3385893 by Primsi: Element translation not loaded when changing...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.