Fatal error when try to register after instalation of generate password module

Created on 16 September 2022, over 3 years ago
Updated 28 August 2023, over 2 years ago

Problem/Motivation

After installation generate password module, I can see this fatal error.

The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\Component\Utility\NestedArray::getValue() must be of the type array, string given, called in C:\xampp\htdocs\rigips\web\core\lib\Drupal\Core\Form\FormStateValuesTrait.php on line 26 in Drupal\Component\Utility\NestedArray::getValue() (line 69 of core\lib\Drupal\Component\Utility\NestedArray.php).

Drupal\Component\Utility\NestedArray::getValue('tKKqa.9}.+B\', Array, NULL) (Line: 26)
Drupal\Core\Form\FormState->getValue('genpass_mode') (Line: 283)
genpass_register_validate(Array, Object)
call_user_func_array('genpass_register_validate', Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'user_register_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('user_register_form', Array, Object) (Line: 588)
Drupal\Core\Form\FormBuilder->processForm('user_register_form', Array, Object) (Line: 320)
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: 564)
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: 159)
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: 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: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  1. Tested on Drupal 9.4.3
  2. Standard drupal register form with confirmation required

It looks like $form_state->setValueForElement($pass_item, $pass); override whole $form_state object, because $pass_item is confirm_password type.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇵🇱Poland lamp5 Rzeszow

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.

  • 🇩🇪Germany Anybody Porta Westfalica

    Confirming the issue for 2.0.x!

    /user/register is broken

  • 🇯🇴Jordan Rajab Natshah Jordan

    I'm with unselected.
    Tested with Drupal 9 and 10 under PHP 8.1

    I confirm the issue in both
    When "Users must enter a password on registration. This is disabled if e-mail verification is enabled above." is selected for "Password handling"

    Drupal 9
    The website encountered an unexpected error. Please try again later.
    TypeError: Drupal\Core\Form\FormState::setValueForElement(): Argument #1 ($element) must be of type array, null given, called in /var/www/html/test/drupal9genpass/web/modules/contrib/genpass/genpass.module on line 270 in Drupal\Core\Form\FormState->setValueForElement() (line 79 of core/lib/Drupal/Core/Form/FormStateValuesTrait.php).
    

    Drupal 10

    The website encountered an unexpected error. Please try again later.
    
    TypeError: Drupal\Core\Form\FormState::setValueForElement(): Argument #1 ($element) must be of type array, null given, called in /var/www/html/test/drupal10genpass/web/modules/contrib/genpass/genpass.module on line 270 in Drupal\Core\Form\FormState->setValueForElement() (line 79 of core/lib/Drupal/Core/Form/FormStateValuesTrait.php).
    

    When the "Require email verification when a visitor creates an account" checkbox is checked

    New users will be required to validate their email address prior to logging into the site, and will be assigned a system-generated password. With this setting disabled, users will be logged in immediately upon registering, and may select their own passwords during registration.

    This is disabled if e-mail verification is enabled above.

    Users must enter a password on registration.
    But the field is hidden in this case.
    Should it be hidden? or should it be visible? and only generate if the user did not add a password

  • 🇯🇴Jordan Rajab Natshah Jordan

    Mmmm, warning too when saved at the Account setting page and unselect to the default config.

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update over 2 years ago
    2 pass
  • @elc opened merge request.
  • Status changed to Needs review over 2 years ago
  • 🇦🇺Australia elc

    The module isn't following the logic path it says that it will:

    It very much makes sense that genpass should not be involved in registration form if e-mail verification is enabled, as there is no password field to adjust.

    The presence of the "pass" form item appears to be a good indication, and also the direct cause of the error when it is missing.

    This needs to be ported to 8.x-1.x too.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 2 years ago
    1 pass
  • 🇦🇺Australia elc

    Patch for the 8.x-1.x branch.

    MR!10 is for the 2.x branch.

  • 🇮🇳India NivethaSubramaniyan

    This issue exits and the given patch works fine. I have detailed the steps and attached the screenshots for the reference.

    Steps to reproduce.
    1) Enabled genpass:^2.0@alpha in drupal 10.1
    2) Go to the account settings page /admin/config/people/accounts
    3) Enable the option: Users must enter a password on registration. This is disabled if e-mail verification is enabled above. and save it
    4) Logout as admin and try registering as a new user
    5) After registering you will get the error message:
    TypeError: Drupal\Core\Form\FormState::setValueForElement(): Argument #1 ($element) must be of type array, null given, called in /var/www/html/web/modules/contrib/genpass/genpass.module on line 270 in Drupal\Core\Form\FormState->setValueForElement() (line 79 of core/lib/Drupal/Core/Form/FormStateValuesTrait.php). [ Attached screenshot].
    6) After applying the patch , it fix the issue.

    • ELC committed 5bff64a6 on 8.x-1.x
      Issue #3310063 by ELC: Only process password when available.
      
    • ELC committed 9b9c41f3 on 2.0.x
      Issue #3310063 by ELC: Only process password when available.
      
  • Status changed to Fixed over 2 years ago
  • 🇦🇺Australia elc

    This works quite well at preventing the error by not attempting to run code against a non-existent "pass" form item.

    What it has shown up, is that GenPass doesn't get involved in generating a password in a number of situations - the issue 📌 Add PasswordGeneratorInterface based service. Remove hook_password Fixed is looking to address this.

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

Production build 0.71.5 2024