Problem/Motivation

I am migrating from Swift mailer to Symfony mailer on a Drupal 9.3.9 site.

Notice: Undefined index: common_adjusters in /htdocs/modules/contrib/symfony_mailer/src/Entity/MailerPolicy.php on line 290
Call Stack
#	Time	Memory	Function	Location
1	0.0009	411008	{main}( )	.../index.php:0
2	0.0065	814928	Drupal\Core\DrupalKernel->handle( )	.../index.php:19
3	0.0212	2361560	Stack\StackedHttpKernel->handle( )	.../DrupalKernel.php:708
4	0.0212	2361560	Drupal\Core\StackMiddleware\NegotiationMiddleware->handle( )	.../StackedHttpKernel.php:23
5	0.0213	2362256	Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle( )	.../NegotiationMiddleware.php:51
6	0.0213	2362256	Drupal\page_cache\StackMiddleware\PageCache->handle( )	.../ReverseProxyMiddleware.php:48
7	0.0215	2364936	Drupal\page_cache\StackMiddleware\PageCache->pass( )	.../PageCache.php:85
8	0.0215	2364936	Drupal\Core\StackMiddleware\KernelPreHandle->handle( )	.../PageCache.php:106
9	0.0301	2562464	Drupal\Core\StackMiddleware\Session->handle( )	.../KernelPreHandle.php:48
10	0.0326	2664800	Symfony\Component\HttpKernel\HttpKernel->handle( )	.../Session.php:58
11	0.0327	2665216	Symfony\Component\HttpKernel\HttpKernel->handleRaw( )	.../HttpKernel.php:80
12	0.1363	8832584	Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure:/htdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:96-98}( )	.../HttpKernel.php:158
13	0.1363	8832584	Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext( )	.../EarlyRenderingControllerWrapperSubscriber.php:97
14	0.1363	8835128	Drupal\Core\Render\Renderer->executeInRenderContext( )	.../EarlyRenderingControllerWrapperSubscriber.php:124
15	0.1364	8835480	Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure:/htdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:121-124}( )	.../Renderer.php:564
16	0.1364	8835480	call_user_func_array:{/htdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123} ( )	.../EarlyRenderingControllerWrapperSubscriber.php:123
17	0.1364	8835512	Drupal\Core\Entity\HtmlEntityFormController->getContentResult( )	.../EarlyRenderingControllerWrapperSubscriber.php:123
18	0.1375	8952256	Drupal\Core\Form\FormBuilder->buildForm( )	.../FormController.php:73
19	0.1376	8952376	Drupal\Core\Form\FormBuilder->retrieveForm( )	.../FormBuilder.php:278
20	0.1378	9021304	call_user_func_array:{/htdocs/core/lib/Drupal/Core/Form/FormBuilder.php:531} ( )	.../FormBuilder.php:531
21	0.1378	9021336	Drupal\symfony_mailer\Form\PolicyEditForm->buildForm( )	.../FormBuilder.php:531
22	0.1387	9064040	Drupal\symfony_mailer\Form\PolicyEditForm->form( )	.../EntityForm.php:106
23	0.1406	9077048	Drupal\symfony_mailer\Entity\MailerPolicy->getCommonAdjusters( )	.../PolicyEditForm.php:53

Steps to reproduce

Comments

JoshaHubbers created an issue. See original summary.

joshahubbers’s picture

Status: Active » Needs review
StatusFileSize
new528 bytes

This patch fixes the issue.

rajab natshah’s picture

Having the same error message

The URL for the page will be "/admin/config/system/mailer/policy/_"

Given that the Symfony Mailer module was installed in a Drupal 9.3.x site
And the Symfony Mailer Back-compatibility module was enabled too
And the Error messages to display was sat to "All messages, with backtrace information"
When navigating to "/admin/config/system/mailer/policy/_" by clicking on the Edit operation for the "*All*" policy
Then the following errors will show up

Error message
Notice: Undefined index: common_adjusters in Drupal\symfony_mailer\Entity\MailerPolicy->getCommonAdjusters() (line 290 of modules/contrib/symfony_mailer/src/Entity/MailerPolicy.php).
Warning: array_flip() expects parameter 1 to be array, null given in Drupal\symfony_mailer\Form\PolicyEditForm->form() (line 53 of modules/contrib/symfony_mailer/src/Form/PolicyEditForm.php).

adamps’s picture

Thanks for the report. I have an alternative patch which has the advantage of initialising every field including those that might be added in future.

adamps’s picture

Status: Needs review » Fixed

Please confirm if this works for you.

  • AdamPS committed 8d3719a on 1.x
    Issue #3275016 by JoshaHubbers, AdamPS, Rajab Natshah: Undefined index:...

Status: Fixed » Closed (fixed)

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