When trying to add a 'To' address in a mailer policy, I got some errors and notification based on the fact, the $addresses variable is NULL, on the moment you try to add the first address.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kensae created an issue. See original summary.

kensae’s picture

Title: Multiple errors in AddressAdjusterBase » Multiple errors in AddressAdjusterBase when no addresses set yet

kensae’s picture

Status: Active » Needs review
adamps’s picture

Please can you explain exactly how to hit the bug and the errors that you see?

I can add a To address without any problems. I see a single error if I save without including any addresses - is that what you mean?

Warning: Invalid argument supplied for foreach() in Drupal\symfony_mailer\Plugin\EmailAdjuster\AddressAdjusterBase->settingsForm() (line 60 of modules/contrib/symfony_mailer/src/Plugin/EmailAdjuster/AddressAdjusterBase.php).

kensae’s picture

I'm trying to add a To address in the policy User » Admin (user awaiting approval) (admin/config/system/mailer/policy/user.register_pending_approval_admin).

- I select the 'To' option and click 'Add Element'

Add To Element

- Then on the 'To' element section I click 'Add Address'

Add Address

- The form to add the address doesn't appear and I've got the folowing error on the ajax callback: TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 152 of /modules/contrib/symfony_mailer/src/Plugin/EmailAdjuster/AddressAdjusterBase.php).

Error on ajax callback

After add adding the patch from my merge request the issue has been resolved: https://git.drupalcode.org/project/symfony_mailer/-/merge_requests/21.patch

adamps’s picture

Thanks for explaining.

Here is an updated patch - please can you take a look?

  • Use the ?? operator to simplify the code
  • Create an empty address if none is present yet
  • Error message if the form is submitted without an address
adamps’s picture

  • AdamPS committed c1cb979 on 1.x
    Issue #3276948 by kensae, AdamPS: Multiple errors in AddressAdjusterBase...
adamps’s picture

Status: Needs review » Fixed

OK I'll commit this so I don't have too many patches hanging around on my dev box. Please let me know if it works for you - we can always do another commit if needed.

kensae’s picture

Patch in #8 works for me. Thanks!

Status: Fixed » Closed (fixed)

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