Problem/Motivation
Drupal\Component\Plugin\Exception\PluginNotFoundException thrown in Drupal\ Core \Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php when saving configuration in PolicyEditForm
The full error:
An unexpected error has occurred. Please try again later.
Drupal\Component\Plugin\Exception\PluginNotFoundException : The "" plugin does not exist. Valid plugin IDs for Drupal\symfony_mailer\Processor\EmailAdjusterManager are: email_plain, email_cc, email_priority, mailer_url_to_absolute, mailer_wrap_and_convert, email_to, email_subject, mailer_default_headers, email_bcc, mailer_hooks, email_body, email_from, email_theme, email_transport, mailer_inline_css, email_skip_sending, email_reply_to in Drupal\ Core \Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php ).
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('', Array) (Line: 17)
Drupal\symfony_mailer\Processor\AdjusterPluginCollection->initializePlugin('') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('') (Line: 160)
Drupal\Core\Plugin\DefaultLazyPluginCollection->setInstanceConfiguration('', Array) (Line: 135)
Drupal\Core\Plugin\DefaultLazyPluginCollection->setConfiguration(Array) (Line: 26)
Drupal\symfony_mailer\Form\PolicyEditForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('mailer_policy_edit_form', Object) (Line: 375)
Drupal\Core\Form\FormBuilder->rebuildForm('mailer_policy_edit_form', Object, Array) (Line: 633)
Drupal\Core\Form\FormBuilder->processForm('mailer_policy_edit_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 44)
Drupal\redirect_after_login\RedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)Steps to reproduce
- Go to
/admin/config/system/mailerand add a newPolicy, After selecting Type and adding Sub-Type it will redirect to Policy edit form. - Select any element and press "Add Element".
- Add element details and press Save on the form.
Please see the video
https://drive.google.com/file/d/1qHwrg8Kub8tGWLzb_3y2DPXHBBv9b_-6/view?usp=sharing.
Proposed resolution
I guess that the #empty_value is causing that error since it is producing empty value for configs (but I am not sure, needs to be verified).
$form['add_actions']['add_select'] = [
'#type' => 'select',
'#options' => $options,
'#empty_value' => '',
'#empty_option' => $this->t('- Select element to add -'),
];| Comment | File | Size | Author |
|---|---|---|---|
| #13 | after.png | 19.71 KB | adamps |
| #13 | before.png | 19.91 KB | adamps |
| #6 | 3398364.patch | 534 bytes | andreic |
| #6 | Screenshot 2024-09-22 at 09.26.28.png | 755.08 KB | andreic |
| 2023-11-01_17-59.png | 222.14 KB | alen simonyan |
Issue fork symfony_mailer-3398364
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
Comment #2
alen simonyan commentedComment #3
adamps commentedIt works for me and no one else has reported. Maybe it is related to something on your site? I suggest to test with creating policy for one of the Core modules.
Comment #4
alen simonyan commentedHi Adam,
I also tried with one of the core modules and it behaves the same
https://drive.google.com/file/d/1X7qqCv8DMaqXBZTSUGuKdzdOqpFZPy49/view?usp=sharing
Comment #5
scotthreha commentedI just completed a Drupal 10 upgrade and I'm getting this same error when I try to add a new element to an existing policy. It worked without problems during the entire development process, but now that I've pushed the upgrade to production it fails.
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for Drupal\symfony_mailer\Processor\EmailAdjusterManager are: mailer_url_to_absolute, email_bcc, email_body, email_cc, mailer_default_headers, email_from, mailer_hooks, mailer_inline_css, email_plain, email_priority, email_reply_to, email_skip_sending, email_subject, email_theme, email_to, email_transport, mailer_wrap_and_convert in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /var/www/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).I should add that this is a policy for email receipts in Drupal Commerce.
Comment #6
andreic commentedThe problem was competing form actions. There was $form['add_actions'] as type 'action' and then $form['actions'] as type 'action.
The $name variable was always empty (attached screenshot) when clicking the Save button, hence the error in this issue.
The solution was to make $form['add_actions'] a container within the existing $form['actions'].
Patch added.
Comment #7
adamps commentedThanks. Drupal.org now uses requests instead of patches please.
Comment #8
andreic commentedOk, done.
Comment #9
adamps commentedPlease put your changes in the 3398364-the--plugin branch then create a merge request. This will cause the tests to run. Thanks.
Comment #12
atul_ghate commentedI have changed patch into the MR, please review.
Comment #13
adamps commentedThanks. For me the result is worse than before. Before the select and button were on the same line, and now they are one below the other - see screenshots attached.
I believe that the buttons are no longer in the container because they still have
$form['add_actions']. Instead it worked for me like this:Please can you check if that still works for you, then update the MR?
Comment #14
andreic commentedI can confirm the above in #13 works fine!
Comment #15
adamps commentedJust needs a MR for the code in #13
Comment #16
atul_ghate commentedI updated MR as per #13, Please review.
Comment #17
adamps commentedIt looks good to me thanks. Please can anyone else test?
We need a MR against 2.x please as that is now the dev branch. I can also commit the 1.x one afterwards as a backport.
Comment #18
adamps commentedComment #20
atul_ghate commentedAdded MR for 2.x branch.
Comment #21
adamps commentedGreat thanks. Let's wait a week and see if someone will test, otherwise I can commit anyway based on #14.
Comment #22
divyansh.gupta commentedI tried replicating this issue on Drupal 10 with module version 2.x, following the steps in the issue summary, but couldn’t reproduce it. If anyone else is experiencing this, please share detailed steps to reproduce, including configuration settings, specific inputs causing the issue, and any error messages or logs. This will help in identifying whether it’s environment-specific or a broader issue.
Comment #24
adamps commented@divyansh.gupta thanks for trying to test. It seems almost random whether a site is affected so maybe we will never know the answer.