Problem/Motivation
When upgrading from Webform 5 to Webform 6 (in this case from 8.x-5.20 to 6.0.0-alpha17), existing handlers using Mautic Webform cease working. PHP errors are thrown when trying to edit the Mautic Webform handler on any webform or when trying to add the handler to a new webform. Selecting to add or edit a Mautic Webform handler in the Webform interface fails to load the handler UI.
When trying to add or edit a Mautic Webform handler to any form, the following PHP error is thrown:
[01-Oct-2020 16:28:20 Australia/Brisbane] Error: Call to a member function get() on null in /path/to/site/docroot/modules/contrib/webform/src/Plugin/WebformHandlerBase.php on line 293 #0 /path/to/site/docroot/modules/contrib/webform/src/Form/WebformHandlerAddForm.php(37): Drupal\webform\Plugin\WebformHandlerBase->isExcluded()
#1 [internal function]: Drupal\webform\Form\WebformHandlerAddForm->buildForm(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\webform\Entity\Webform), 'mautic')
#2 /path/to/site/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(532): call_user_func_array(Array, Array)
#3 /path/to/site/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(278): Drupal\Core\Form\FormBuilder->retrieveForm('webform_handler...', Object(Drupal\Core\Form\FormState))
#4 /path/to/site/docroot/core/lib/Drupal/Core/Controller/FormController.php(91): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\webform\Form\WebformHandlerAddForm), Object(Drupal\Core\Form\FormState))
#5 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#6 /path/to/site/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#7 /path/to/site/docroot/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#8 /path/to/site/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#9 /path/to/site/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#10 /path/to/site/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 /path/to/site/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#12 /path/to/site/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /path/to/site/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /path/to/site/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /path/to/site/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /path/to/site/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /path/to/site/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /path/to/site/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /path/to/site/docroot/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /path/to/site/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#21 {main}Steps to reproduce
- Upgrade from Webform 5 to Webform 6 (with Webform Mautic already installed).
- Navigate to any existing Webform using a Webform Mautic handler and click 'Edit' on the handler.
- See that clicking 'Edit' no longer has the intended effect and check logs for the above error.
- Note that submissions are no longer passed to Mautic from any existing forms using a Webform Mautic handler.
Proposed resolution
The issue appears to lie in WebformMauticHandler.php as it contains code that has been changed and/or deprecated in Webform 6.
The solution appears to be updating WebformMauticHandler.php to replace the changed and/or deprecated code with code that is supported by Webform 6. Looking to the latest updates to Webform's RemotePostWebformHandler.php may be of assistance, as WebformMauticHandler.php appears to be based on an older version of that handler.
As the Varbase project recently moved from using Webform 5 to Webform 6, this issue may be affecting a large number of installations previously integrated with Mautic.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | webform.6-incompatible--3174456-5.patch | 2.52 KB | sneo |
Issue fork webform_mautic-3174456
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:
- 8.x-1.x
changes, plain diff MR !2
- 3174456-incompatibility-with-webform
changes, plain diff MR !1
Comments
Comment #2
gavagai commentedDo we know if there are plans to fix this?
Comment #5
thomas-at-passerelle commentedThis handler seems to be based on \web\modules\contrib\webform\src\Plugin\WebformHandler\RemotePostWebformHandler.php
I modified it according to it, and it seems to work well
Comment #6
thomas-at-passerelle commentedSorry, it's my first time here, i needed this module too. So i changed it to be compatible with webform 6.x
I made a commit, but i don't really know how it works
I used the proposed solution to do it.
Comment #10
avpadernoComment #11
sneo commentedJust a patch of thomas version because i got the same issue.
Until it' commited to master, we can use this patch in composer ;)
Comment #12
philipnorton42 commentedThanks for the patch. I've been trying this out for the last couple of days and it works really well.
Comment #13
ultimikeThe patch is working for me as well :)
thanks @thomas-at-passerelle and @seno!
-mike
Comment #14
philyPatch at #11 is working for me using Drupal 9.3.0, Webform 6.1.2, Webform Mautic 8.x-1.1 and Mautic 4.1.0
No more error in log and Webform data are saved to Mautic forms and contacts.
Thanks
Comment #15
mohammed j. razemComment #17
mohammed j. razemThanks for the patch. Fixed and committed, new release on the way.
Comment #18
mohammed j. razemComment #20
socialnicheguru commentedwas this ever added to the 2.0 version?