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

  1. Upgrade from Webform 5 to Webform 6 (with Webform Mautic already installed).
  2. Navigate to any existing Webform using a Webform Mautic handler and click 'Edit' on the handler.
  3. See that clicking 'Edit' no longer has the intended effect and check logs for the above error.
  4. 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.

CommentFileSizeAuthor
#11 webform.6-incompatible--3174456-5.patch2.52 KBsneo
Command icon 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

mitchellwillocks created an issue. See original summary.

gavagai’s picture

Do we know if there are plans to fix this?

thomas-at-passerelle made their first commit to this issue’s fork.

Sorry it's my first time on drupal, i made an account, just to modify this module.
I used the proposed solution to make the patch, It works well in my project.

thomas-at-passerelle’s picture

This 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

thomas-at-passerelle’s picture

Sorry, 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.

avpaderno’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
sneo’s picture

StatusFileSize
new2.52 KB

Just a patch of thomas version because i got the same issue.
Until it' commited to master, we can use this patch in composer ;)

philipnorton42’s picture

Thanks for the patch. I've been trying this out for the last couple of days and it works really well.

ultimike’s picture

The patch is working for me as well :)

thanks @thomas-at-passerelle and @seno!

-mike

phily’s picture

Patch 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

mohammed j. razem’s picture

Status: Active » Needs review

mohammed j. razem’s picture

Thanks for the patch. Fixed and committed, new release on the way.

mohammed j. razem’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

socialnicheguru’s picture

was this ever added to the 2.0 version?