Argument #1 ($form_settings) must be of type array, null given

Created on 30 May 2023, over 1 year ago

TypeError: Drupal\honeypot\Form\HoneypotSettingsForm::getFormSettingsValue(): Argument #1 ($form_settings) must be of type array, null given, called in /var/www/html/web/modules/contrib/honeypot/src/Form/HoneypotSettingsForm.php on line 176 in Drupal\honeypot\Form\HoneypotSettingsForm->getFormSettingsValue() (line 316 of /var/www/html/web/modules/contrib/honeypot/src/Form/HoneypotSettingsForm.php)

Step to reproduce:
1. Install module via composer - composer require 'drupal/honeypot:^2.1'
2. Goto Extend > Honepot > Configure (/admin/config/content/honeypot)
3. You will get The website encountered an unexpected error. Please try again later.

Possible solution:
To add a check before initializing $form_settings in HoneypotSettingsForm

🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇮🇳India shobhit_juyal New Delhi

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

Comments & Activities

  • Issue created by @shobhit_juyal
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    27 pass
  • @shobhit_juyal opened merge request.
  • Status changed to Needs review over 1 year ago
  • Status changed to Postponed: needs info over 1 year ago
  • 🇺🇸United States tr Cascadia

    I can't reproduce this. Tried with Drupal 9.5 and Drupal 10.1 on simplytest.me. The Honeypot module also has automated tests which are constantly running on drupal.org; one of these tests installs Honeypot and visits the config page, and does not cause an error.

    The honeypot.settings config object is initialized upon install, and form_settings is declared and initialized as an array with contents.

    honeypot.settings.form_settings should never be NULL or anything other than an array.

    Regardless, if it is being set to NULL somewhere, then that's what should be fixed. It is wrong to just test to see if it's an array and set it to an empty array if not. Perhaps your install is setting values for the honeypot.settings object - this might be done in an install profile, or in another module that uses Honeypot, for example. Or if you are installing the site from config, then your config could have wrong values.

  • 🇮🇳India shobhit_juyal New Delhi

    My apologies for the delay in responding. Your patience is appreciated.

    Yes, you are right about the issue. The module installation was not properly done on that moment (might be some other issues) and after that I was facing that error. Later I thought that if it has occurred then it should be handled and hence I created this issue.

    Please close this if it should.

  • Status changed to Closed: works as designed over 1 year ago
  • 🇺🇸United States tr Cascadia
  • 🇫🇷France planceleur

    Hi,
    I just have a similar issue with D10.3.1
    The module was installed with composer require drupal/honeypot.
    Go to the config page and received this error:
    The website encountered an unexpected error. Try again later.

    TypeError: Drupal\honeypot\Form\HoneypotSettingsForm::getFormSettingsValue(): Argument #1 ($form_settings) must be of type array, null given, called in /var/www/html/web/modules/contrib/honeypot/src/Form/HoneypotSettingsForm.php on line 177 in Drupal\honeypot\Form\HoneypotSettingsForm->getFormSettingsValue() (line 317 of modules/contrib/honeypot/src/Form/HoneypotSettingsForm.php).
    Drupal\honeypot\Form\HoneypotSettingsForm->buildForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 536)
    Drupal\Core\Form\FormBuilder->retrieveForm('honeypot_settings_form', Object) (Line: 284)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->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: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    Thank for this module!
    Philippe

  • 🇺🇸United States mwebaze

    I am getting the error when installed on D11.07 and using version 2.2. Using drush cr doesn't seem to help.

    TypeError: Drupal\honeypot\Form\HoneypotSettingsForm::getFormSettingsValue(): Argument #1 ($form_settings) must be of type array, null given, called in /opt/drupal/web/modules/contrib/honeypot/src/Form/HoneypotSettingsForm.php on line 181 in Drupal\honeypot\Form\HoneypotSettingsForm->getFormSettingsValue() (line 321 of /opt/drupal/web/modules/contrib/honeypot/src/Form/HoneypotSettingsForm.php).
    
Production build 0.71.5 2024