I think I found a bug, but it seems so obvious that I'm wondering if I missed or misconfigured something myself.

When sending a test email from /admin/config/development/reroute_email/test, I got a fatal error: Object of class Drupal\Core\Language\Language could not be converted to string in Drupal\Core\StringTranslation\Translator\CustomStrings->getLanguage(). This seems to be solved by changing a single line in TestEmailForm::submitForm(). Diff:

@@ -103,7 +103,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
     $to = $form_state->getValue(['to']);
     $param_keys = ['cc', 'bcc', 'subject', 'body'];
     $params = array_intersect_key($form_state->getValues(), array_flip($param_keys));
-    $langcode = $this->languageManager->getDefaultLanguage();
+    $langcode = $this->languageManager->getDefaultLanguage()->getId();

     // Send email with drupal_mail.
     $message = $this->mailManager->mail('reroute_email', 'test_email_form', $to, $langcode, $params);

Is this indeed the simple solution to an obvious bug?

Comments

marcvangend created an issue. See original summary.

oleksandr senenko’s picture

Assigned: Unassigned » oleksandr senenko
Issue tags: +LutskGCW19
oleksandr senenko’s picture

Hello.
Thanks Marc for you solution. I implemented it in patch. Tested on Drupal 8.6.7 and Reroute Email 8.x-1.x

Regards.

oleksandr senenko’s picture

Assigned: oleksandr senenko » Unassigned
Status: Active » Reviewed & tested by the community

  • bohart committed eacf3f3 on 8.x-1.x authored by asenenko
    Issue #3003536 by asenenko, marcvangend, bohart: TestEmailForm passes...
bohart’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x-dev version.

Thanks, @all!

Status: Fixed » Closed (fixed)

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