Problem/Motivation

If some modules don't exist (ie. simplenews), this notice appears in the "Add policy" page.

Notice: Undefined index: label in Drupal\symfony_mailer\Form\PolicyAddForm->form() (line 21 of modules/contrib/symfony_mailer/src/Form/PolicyAddForm.php)

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

balis_m created an issue. See original summary.

balis_m’s picture

Status: Active » Needs review
adamps’s picture

Status: Needs review » Needs work

Great thanks for the report.

That fix works, however I prefer a different approach. We don't want all code ever written that calls $emailBuilderManager->getDefinitions() to have to exclude the invalid ones. If the module doesn't exist, it would be better if the definition was automatically deleted.

I believe we can achieve this by adding code in EmailBuilderManager. At the top of this function we could add $definition['provider'] = '_'; . This should cause DefaultPluginManager::findDefinitions() to decide that the provider doesn't exist and remove the definition. This idea comes from reading the code - I haven't tested it yet.

balis_m’s picture

Status: Needs work » Needs review

@AdamPS I agree that the approach you suggested is better and also works.

adamps’s picture

Status: Needs review » Needs work

Great thanks. That line is a bit mysterious so please can we add a comment something like this?

// Set a dummy provider that will cause the definition to be removed.
// @see DefaultPluginManager::findDefinitions()

balis_m’s picture

Status: Needs work » Needs review

@AdamPs I've added the suggested comment.

adamps’s picture

Status: Needs review » Fixed

Great thanks

  • AdamPS committed d189afe on 1.x authored by balis_m
    Issue #3254102 by balis_m, AdamPS: Notice: Undefined index: label in...

Status: Fixed » Closed (fixed)

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