Problem/Motivation

After installation it's not letting me add the "Webform Navigation" handler. I press the button and nothing happens.
I am getting this message on dblog. Is this an issue or is it my operator error? :-)

Error: Call to a member function get() on null in Drupal\webform\Plugin\WebformHandlerBase->isExcluded() (line 292 of /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/modules/webform/src/Plugin/WebformHandlerBase.php) 

#0 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/modules/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), 'webform_navigat...')
#2 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/Form/FormBuilder.php(532): call_user_func_array(Array, Array)
#3 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/Form/FormBuilder.php(278): Drupal\Core\Form\FormBuilder->retrieveForm('webform_handler...', Object(Drupal\Core\Form\FormState))
#4 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/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 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#7 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#8 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#9 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#10 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#12 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /Users/melodycorp/Sites/devdesktop/drupal-8.9.1/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#21 {main}</p>

Comments

melodycorp created an issue. See original summary.

chrisla’s picture

I receive the same error along with:

Notice: Undefined index: debug in Drupal\webformnavigation\Plugin\WebformHandler\WebformNavigationHandler->buildConfigurationForm() (line 95 of /var/www/html/web/modules/contrib/webformnavigation/src/Plugin/WebformHandler/WebformNavigationHandler.php)

Investigating isExcluded() method and it appears that $this->configFactory property is null during this method call and so the get() method cannot be called on nothing.

return $this->configFactory->get('webform.settings')->get('handler.excluded_handlers.' . $this->pluginDefinition['id']) ? TRUE : FALSE;

chrisla’s picture

Looks like $this->configFactory is outdated in Drupal 9 and current method is to use Drupal::configFactory

After looking at how other modules use configFactory, I changed

return $this->configFactory->get('webform.settings')->get('handler.excluded_handlers.' . $this->pluginDefinition['id']) ? TRUE : FALSE;

to

$config_factory = \Drupal::configFactory();
return $config_factory->get('webform.settings')->get('handler.excluded_handlers.' . $this->pluginDefinition['id']) ? TRUE : FALSE;

And I am now able to load the handler with no errors. Now let's see if it works.

chrisla’s picture

Issue summary: View changes
chrisla’s picture

Version: 8.x-1.0-alpha9 » 8.x-1.0-alpha11
Priority: Normal » Critical
chrisla’s picture

Everything appears to be working as expected. This is my first time using the module, but I can navigate forwards and backwards on the forms with the handler added now. And form still does validation before being submitted. So I think with my fix above, all is working.

rymcveigh’s picture

@endless_wander would you propose a patch for D9? That way we can get this fix in :)

See https://www.drupal.org/project/webformnavigation/git-instructions for more info on how to do this.

rymcveigh’s picture

Status: Active » Needs work
chrisla’s picture

Status: Needs work » Needs review
StatusFileSize
new6.55 KB

This patch adds the isExcluded method to WebformNavigationHandler.php and solves the problem

chrisla’s picture

StatusFileSize
new6.58 KB

Wrong patch, should be this one

rymcveigh’s picture

Looks like this issue pertains to the webform module itself. The isExcluded function is defined in webform's WebformHandlerInterface and not in this module. Did you try updating to a more recent version of the webform module?

rymcveigh’s picture

Status: Needs review » Closed (works as designed)