Problem/Motivation

I have upgraded from version 8.x-1.5 to 8.x-1.6 and when submitting a form with the webform_simplenews handler enabled i get the following error:

Error: Call to undefined method Drupal\simplenews\Subscription\SubscriptionManager::() in Drupal\webform_simplenews_handler\Plugin\WebformHandler\SubmissionSimplenewsWebformHandler->postSave() (line 375 of C:\wamp64\www\dasta\web\modules\contrib\webform_simplenews_handler\src\Plugin\WebformHandler\SubmissionSimplenewsWebformHandler.php)

#0 C:\wamp64\www\dasta\web\modules\contrib\webform\src\Entity\Webform.php(2751): Drupal\webform_simplenews_handler\Plugin\WebformHandler\SubmissionSimplenewsWebformHandler->postSave(Object(Drupal\webform\Entity\WebformSubmission), false, NULL)
#1 C:\wamp64\www\dasta\web\modules\contrib\webform\src\WebformSubmissionStorage.php(1213): Drupal\webform\Entity\Webform->invokeHandlers('postSave', Object(Drupal\webform\Entity\WebformSubmission), false, NULL)
#2 C:\wamp64\www\dasta\web\modules\contrib\webform\src\WebformSubmissionStorage.php(1121): Drupal\webform\WebformSubmissionStorage->invokeWebformHandlers('postSave', Object(Drupal\webform\Entity\WebformSubmission), false)
#3 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\Entity\EntityStorageBase.php(523): Drupal\webform\WebformSubmissionStorage->doPostSave(Object(Drupal\webform\Entity\WebformSubmission), false)
#4 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php(804): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\webform\Entity\WebformSubmission))
#5 C:\wamp64\www\dasta\web\modules\contrib\webform\src\WebformSubmissionStorage.php(984): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\webform\Entity\WebformSubmission))
#6 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\Entity\EntityBase.php(339): Drupal\webform\WebformSubmissionStorage->save(Object(Drupal\webform\Entity\WebformSubmission))
#7 C:\wamp64\www\dasta\web\modules\contrib\webform\src\Entity\WebformSubmission.php(887): Drupal\Core\Entity\EntityBase->save()
#8 C:\wamp64\www\dasta\web\modules\contrib\webform\src\WebformSubmissionForm.php(1972): Drupal\webform\Entity\WebformSubmission->save()
#9 [internal function]: Drupal\webform\WebformSubmissionForm->save(Array, Object(Drupal\Core\Form\FormState))
#10 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\Form\FormSubmitter.php(114): call_user_func_array(Array, Array)
#11 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\Form\FormSubmitter.php(52): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#12 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\Form\FormBuilder.php(592): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#13 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\Form\FormBuilder.php(320): Drupal\Core\Form\FormBuilder->processForm('webform_submiss...', Array, Object(Drupal\Core\Form\FormState))
#14 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\Entity\EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\webform\WebformSubmissionForm), Object(Drupal\Core\Form\FormState))
#15 C:\wamp64\www\dasta\web\modules\contrib\webform\src\Entity\Webform.php(1243): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\webform\Entity\WebformSubmission), 'add')
#16 C:\wamp64\www\dasta\web\modules\contrib\webform\src\Controller\WebformEntityController.php(76): Drupal\webform\Entity\Webform->getSubmissionForm()
#17 [internal function]: Drupal\webform\Controller\WebformEntityController->addForm(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\webform\Entity\Webform))
#18 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#19 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\Render\Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#21 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#22 C:\wamp64\www\dasta\vendor\symfony\http-kernel\HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#23 C:\wamp64\www\dasta\vendor\symfony\http-kernel\HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#24 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\StackMiddleware\Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 C:\wamp64\www\dasta\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 C:\wamp64\www\dasta\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 C:\wamp64\www\dasta\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 C:\wamp64\www\dasta\web\core\lib\Drupal\Core\DrupalKernel.php(709): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 C:\wamp64\www\dasta\web\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#33 {main}

I use Drupal core version 9.4.9 and simplenews version 3.0.0-beta4.

It seems that compared to version 8.x-1.5 there is a change in src\Plugin\WebformHandler\SubmissionSimplenewsWebformHandler.php from:

$this->subscriptionManager->subscribe($email_value, $newsletter_id, NULL, 'website');

to:

$action = $this->configuration['action'];
$this->subscriptionManager->$action($email_value, $newsletter_id, NULL, 'website');

The problem is that $this->configuration['action'] is empty for existing handlers. If I update the handler from the UI, the configuration value is saved and the handler works without errors.

As a temporary solution one should visit all webform_simplenews handlers and save their settings choosing either subscribe or unsubscribe as the action. However, the module should handle the case of existing handlers when updating.

Comments

plessas created an issue. See original summary.

netsliver’s picture

Yes sorry, no hook_update, there is a new parameter in the handler to subscribe or unsubscribe, update your handler config

vuil’s picture

Version: 8.x-1.6 » 2.0.x-dev
vuil’s picture

Priority: Major » Normal

@netsilver Any contribution? Thanks.

vuil’s picture

Status: Active » Fixed

Resolved in the latest 2.0.x stable release. I close the issue as Fixed.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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