Problem/Motivation
There seems to be a bug in the code which generates the form to request a new confirmation mail. When the button is clicked, an error message occurs and no mail is generated.
Steps to reproduce
- Sign up to a newsletter as anonymous user
- You'll get a confimation mail with a link you need to click in order to subsribe.
- Wait 24 hours or more before clicking the link. The embedded code is now expired and you'll need a new one. Simplenews will show a page with a button "Request new confirmation mail".
- Click the button.
- EXPECTED: A new confirmation mail with a new link to click. ACTUAL: No mail is generated. Insead, a PHP error "Exception: Unrecognised key confirm in simplenews_mail() (Line 616 in /var/www/html/web/modules/contrib/simplenews/simplenews.module)." happens.
#0 [internal function]: simplenews_mail('confirm', Array, Array)
#1 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(400): call_user_func_array(Object(Closure), Array)
#2 /var/www/html/web/modules/contrib/symfony_mailer/src/Plugin/EmailBuilder/LegacyEmailBuilder.php(124): Drupal\Core\Extension\ModuleHandler->invoke('simplenews', 'mail', Array)
#3 [internal function]: Drupal\symfony_mailer\Plugin\EmailBuilder\LegacyEmailBuilder->build(Object(Drupal\symfony_mailer\Email))
#4 /var/www/html/web/modules/contrib/symfony_mailer/src/Email.php(490): call_user_func(Array, Object(Drupal\symfony_mailer\Email))
#5 /var/www/html/web/modules/contrib/symfony_mailer/src/Mailer.php(179): Drupal\symfony_mailer\Email->process()
#6 /var/www/html/web/modules/contrib/symfony_mailer/src/Mailer.php(149): Drupal\symfony_mailer\Mailer->doSend(Object(Drupal\symfony_mailer\Email))
#7 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\symfony_mailer\Mailer->Drupal\symfony_mailer\{closure}()
#8 /var/www/html/web/modules/contrib/symfony_mailer/src/Mailer.php(158): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#9 /var/www/html/web/modules/contrib/symfony_mailer/src/Email.php(292): Drupal\symfony_mailer\Mailer->send(Object(Drupal\symfony_mailer\Email))
#10 /var/www/html/web/modules/contrib/symfony_mailer/src/MailManagerReplacement.php(92): Drupal\symfony_mailer\Email->send()
#11 /var/www/html/web/modules/contrib/simplenews/src/Form/RequestHashForm.php(79): Drupal\symfony_mailer\MailManagerReplacement->mail('simplenews', 'confirm', 'jane.doe@zebral...', 'de', Array, 'drupal@zebralog...')
#12 [internal function]: Drupal\simplenews\Form\RequestHashForm->submitForm(Array, Object(Drupal\Core\Form\FormState))
#13 /var/www/html/web/core/lib/Drupal/Core/Form/FormSubmitter.php(129): call_user_func_array(Array, Array)
#14 /var/www/html/web/core/lib/Drupal/Core/Form/FormSubmitter.php(67): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#15 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(606): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#16 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('simplenews_requ...', Array, Object(Drupal\Core\Form\FormState))
#17 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(224): Drupal\Core\Form\FormBuilder->buildForm('\\Drupal\\simplen...', Object(Drupal\Core\Form\FormState))
#18 /var/www/html/web/modules/contrib/simplenews/src/Controller/ConfirmationController.php(87): Drupal\Core\Form\FormBuilder->getForm('\\Drupal\\simplen...', 'confirm', Array)
#19 [internal function]: Drupal\simplenews\Controller\ConfirmationController->confirmSubscribe('6', '1736532312', 'hVxZMHQiWznbKdH...', false)
#20 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#21 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#22 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#23 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#24 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#25 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#26 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#37 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#38 {main}
This happens in "RequestHashForm". Line 79 apparently uses the key "confirm", which isn't expected anymore in "simplenews_mail". I think this is built in "ConfirmationController" in line 87:
$build = $this->formBuilder()->getForm('\Drupal\simplenews\Form\RequestHashForm', 'confirm', $context);
This should use "subscribe_combined" instead of "confirm".
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes