Problem/Motivation

When trying to edit an invite type, the user is confronted with a fatal error: The website encountered an unexpected error. Please try again later.

In the logs I found the following corresponding error; TypeError: explode(): Argument #2 ($string) must be of type string, Drupal\Core\Config\ImmutableConfig given in explode() (line 91 of /app/www/modules/contrib/invite/src/Form/InviteTypeForm.php)

Steps to reproduce

Go to Settings > People > Invite > Invite Settings > Invite List Type (/admin/structure/invite_type), and edit existing invite type.

CommentFileSizeAuthor
#10 invite-3278856-10-edit-fix.patch3.6 KBdale42

Issue fork invite-3278856

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

tijsdeboeck created an issue. See original summary.

tijsdeboeck’s picture

Issue summary: View changes

tijsdeboeck’s picture

Status: Active » Needs review

Updated my merge request

tijsdeboeck’s picture

dale42’s picture

Status: Needs review » Needs work

Code review

- The patch works
- Correctly identified the changes in #3276084: Fix all dependency injection in the Invite as the source of the issue
- Undid the specific change causing the issue

Proposed improvement

There were a couple of issues with changes in #3276084:

  • It does not use the the attribute named configFactory. There is a method named configFactory on FormBase. The new code used the method inherited from FormBase, $this->configFactory(), not the attribute it created to hold the service object, $this->configFactory.
  • It did not need to dependancy inject config.factory, it could have directly called $this->configFactory().

I don't think we should still use dependancy injection. I propose changing the existing MR by replacing the \Drupal::config call with $this->configFactory():

    $sending_methods = $this->configFactory()
      ->get('invite.invite_sender.' . $invite_type->getType())
      ->get('sending_methods');
dale42’s picture

Opps, I think I was looking at MR 11 instead of MR 12.

So, what I propose is:

  • Remove the explicite dependency injection of config.factory and remove $configFactory
  • Switch the code block to use $this->configFactory()->get()
dale42’s picture

Status: Needs work » Needs review
StatusFileSize
new3.6 KB

@tijsdeboeck: I didn't want to update your MR directly, that seems rude.

Attached is a patch with the changes I mentioned. It also includes removing the dependency injection for messenger. It turns out that, like config factory, one of the parent classes already includes it.

The patch:

  • Removes dependency injection for config factory
  • Switches to using the parent class ->configFactory() method
  • Removes dependency injection for messenger
  • Switches to using the parent class ->messenger() method
  • Adds the missing get to the ->configFactory() call
tijsdeboeck’s picture

Status: Needs review » Reviewed & tested by the community

Hi @dale42, thanks for the patch! I didn't have time to look at your previous comments, and I really don't mind anyone changing my MR's ;)

I just tried it out patch #10, and it works perfectly! 👍