Configuration - "Test Email" tab not functional, throws error.

Created on 31 January 2023, about 2 years ago
Updated 1 February 2023, about 2 years ago

Problem/Motivation

When you go to /admin/config/system/elastic_email/test

TypeError: Drupal\elastic_email\Plugin\Mail\ElasticEmailMailSystem::__construct(): Argument #1 ($messenger) must be of type Drupal\Core\Messenger\MessengerInterface, array given, called in /app/web/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php on line 25 in Drupal\elastic_email\Plugin\Mail\ElasticEmailMailSystem->__construct() (line 93 of modules/contrib/elastic_email/src/Plugin/Mail/ElasticEmailMailSystem.php).

Steps to reproduce

Go to /admin/config/system/elastic_email/test

Proposed resolution

Since it's a plugin, use the ContainerFactoryPluginInterface instead of

📌 Task
Status

Fixed

Version

4.0

Component

Code

Created by

🇨🇦Canada No Sssweat

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

Comments & Activities

  • Issue created by @No Sssweat
  • @no-sssweat opened merge request.
  • Status changed to Needs review about 2 years ago
  • 🇨🇦Canada No Sssweat

    Created an MR, please review.

  • First commit to issue fork.
  • 🇩🇪Germany jurgenhaas Gottmadingen

    There was quite a bit more to be done. If implementing your own constructor for a plugin, the class needs to extend the PluginBase and call that constructor as well. Otherwise, the 3 first variables remain undefined and could easily cause other issues elsewhere. I've also updated the code for code style and optimized the use of config variables.

    Please have a look, what you think. I have committed directly to the MR !4.

  • 🇨🇦Canada No Sssweat

    First, thanks for reviewing :)

    If implementing your own constructor for a plugin, the class needs to extend the PluginBase and call that constructor as well. Otherwise, the 3 first variables remain undefined

    I don't see that in my debugger, those are defined.

    Might be because its an annotations-based plugin.

    However, doing an extend of PluginBase will give access to useful traits and methods. As the PluginBase says,

    Base class for plugins wishing to support metadata inspection.

    Plus, it's seems to be the more drupal-ly correct/good practice thing to do. So I agree with doing this.

    Please have a look, what you think. I have committed directly to the MR !4.

    Looks good! feel free to merge whenever you like.

  • Status changed to Fixed about 2 years ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I don't see that in my debugger, those are defined.

    Well, the scope of those variables is local to the constructor. But they need to be made available to the base class which uses them for certain actions.

    A little tip for the next issue, as it seems we may work together on this project for a while, when you have reviewed the code and think it'S ready to go, you can set the status of the issue to RTBC.

    I've now merged the MR and set it to fixed. Thanks for your work on this!

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

Production build 0.71.5 2024