Error: Call to a member function get() on null

Created on 27 October 2022, over 2 years ago
Updated 5 July 2023, almost 2 years ago

Problem/Motivation

Nothing happens when I click to add a Stripe handler to a webform. An error is shown in the log.

Steps to reproduce

Using Drupal 9.4, and these relevant modules:

        "drupal/stripe": "^1.0",
        "drupal/stripe_webform": "^1.2",
        "drupal/webform": "^6.2@beta",

Error:

Error: Call to a member function get() on null in Drupal\webform\Plugin\WebformHandlerBase->isExcluded() (line 310 of /var/www/html/web/modules/contrib/webform/src/Plugin/WebformHandlerBase.php)
#0 /var/www/html/web/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), 'stripe')
#2 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(531): call_user_func_array(Array, Array)
#3 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(278): Drupal\Core\Form\FormBuilder->retrieveForm('webform_handler...', Object(Drupal\Core\Form\FormState))
#4 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(73): 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 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#7 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#8 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#9 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#10 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(159): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
...

Proposed resolution

Specify which versions of Webform are supported in the info file by adding version constraints to the dependency.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom Spiros_alimba

    Same config as above but on Core: 9.5.9 I get the following.

    The website encountered an unexpected error. Please try again later.
    Error: Call to a member function get() on null in Drupal\stripe_webform\Plugin\WebformHandler\StripeWebformHandler->postSave() (line 235 of modules/contrib/stripe_webform/src/Plugin/WebformHandler/StripeWebformHandler.php).
    Drupal\stripe_webform\Plugin\WebformHandler\StripeWebformHandler->postSave(Object, , NULL) (Line: 2765)
    Drupal\webform\Entity\Webform->invokeHandlers('postSave', Object, , NULL) (Line: 1212)
    Drupal\webform\WebformSubmissionStorage->invokeWebformHandlers('postSave', Object, ) (Line: 1120)
    Drupal\webform\WebformSubmissionStorage->doPostSave(Object, ) (Line: 523)
    Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 983)
    Drupal\webform\WebformSubmissionStorage->save(Object) (Line: 339)
    Drupal\Core\Entity\EntityBase->save() (Line: 913)
    Drupal\webform\Entity\WebformSubmission->save() (Line: 2002)
    Drupal\webform\WebformSubmissionForm->save(Array, Object)
    call_user_func_array(Array, Array) (Line: 114)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
    Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
    Drupal\Core\Form\FormBuilder->processForm('webform_submission_become_an_awid_free_organization_add_form', Array, Object) (Line: 325)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
    Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add') (Line: 1257)
    Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 77)
    Drupal\webform\Controller\WebformEntityController->addForm(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
    Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
  • 🇬🇧United Kingdom Spiros_alimba

    Uppon some tinkering with the module, what solves the issue is the following:
    Drupal\stripe_webform\Plugin\WebformHandler\StripeWebformHandler->postSave() (line 235)

    public function postSave(WebformSubmissionInterface $webform_submission, $update = TRUE) {
        // If update do nothing
        if ($update) {
          return;
        }
    
       // Added this condition
       if (!is_object($this->configFactory)) {
         return;
       }
    
        $uuid = $this->configFactory->get('system.site')->get('uuid');
    
        $config = $this->configFactory->get('stripe.settings');
    
  • It would probably be better to get the Drupal service instead of returning, and maybe do it in a constructor or something.

       // Make sure config factory exists.
       if (!isset($this->configFactory)) {
         $this->configFactory = \Drupal::configFactory();
       }
    
  • First commit to issue fork.
  • Status changed to Closed: outdated almost 2 years ago
  • 🇧🇪Belgium matthijs

    I was gonna open an MR to fix this, but a fix was already committed.

Production build 0.71.5 2024