Warning: Undefined array key "form_alter" in Drupal\symfony_mailer\MailerHelper->formAlter() (line 211 of modules/contrib/symfony_mailer/src/MailerHelper.php).

Created on 7 September 2023, 10 months ago
Updated 13 February 2024, 5 months ago

Problem/Motivation

The module causes the error

Warning: Undefined array key "form_alter" in Drupal\symfony_mailer\MailerHelper->formAlter() (line 211 of modules/contrib/symfony_mailer/src/MailerHelper.php).
and

Warning: foreach() argument must be of type array|object, null given in Drupal\symfony_mailer\MailerHelper->formAlter() (line 211 of modules/contrib/symfony_mailer/src/MailerHelper.php).

Steps to reproduce

Open a page with form, e.g. admin/reports/updates or /node/add/article

๐Ÿ› Bug report
Status

Closed: works as designed

Version

1.3

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly Giuseppe87

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

Comments & Activities

  • Issue created by @Giuseppe87
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly Giuseppe87

    Attached a patch

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ayush.pandey

    Tried module with version 1.3.1, and the issue is not reproducible by accessing the pages admin/reports/updates or /node/add/article . Please add some more steps that was used to reproduce the issue.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Mohd Sahzad

    I have fixed this issue Undefined array key "form_alter"

  • Status changed to Postponed: needs info 10 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom AdamPS

    I agree with #3 - this needs steps to reproduce. \Drupal\symfony_mailer\Annotation\EmailBuilder sets $form_alter = [] so how can it be undefined?

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly Giuseppe87

    @AdamPS I don't get how $this->formAlter = []; would help $definition['form_alter']

    However I can't replicate anymore - I suspect this warning was in relationship with some other contrib module, as I updated a lot of them after this report.

    Therefore sorry for your time, I'm going to close this issue.

  • Status changed to Closed: works as designed 9 months ago
  • ๐Ÿ‡ต๐Ÿ‡ฐPakistan Khalid Ansari

    Khalid Ansari โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ต๐Ÿ‡ฐPakistan Khalid Ansari

    I encountered the identical problem, which emerged from my attempt to modify the Drupal Commerce email builder class via hook_mailer_builder_info_alter. hook

    In my custom module replaced $email_builders['commerce']['class'] with $email_builders['commerce_order_type']['class']

    /**
     * Implements hook_mailer_builder_info_alter().
     */
    function CUSTOM_MODULE_mailer_builder_info_alter(array &$email_builders) {
      $email_builders['commerce']['class'] = 'Drupal\CUSTOM_MODULE\Plugin\EmailBuilder\LegacyEmailBuilder';
      $email_builders['commerce_order_type']['class'] = 'Drupal\CUSTOM_MODULE\Plugin\EmailBuilder\LegacyEmailBuilder';
    }
    
Production build 0.69.0 2024