Problem/Motivation

On the configuration page at /admin/config/people/passwords, the “Minimum password length” field is not required.
If the field is left empty, better_passwords_after_build() calls t() with a NULL value:

$element['#description'] .= '<br/>' . t(
  'Passwords must be at least @num characters.',
  ['@num' => $config->get('length')] // <--- $config->get('length') can be NULL
);

This triggers the same core error as in:
https://www.drupal.org/project/drupal/issues/3554974
"TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in core/lib/Drupal/Component/Render/FormattableMarkup.php on line 238"

Steps to reproduce

  • Install and enable Better Passwords.
  • Go to /admin/config/people/passwords.
  • Leave Minimum password length empty.
  • Save configuration.
  • Go to /admin/people/create and you get a WSOD

Proposed resolution

Wrap the code in a conditional check, the same way it is already done for the strength setting directly below it:

if (!empty($config->get('length'))) {
  $element['#description'] .= '<br/>' . t(
    'Passwords must be at least @num characters.',
    ['@num' => $config->get('length')]
  );
}
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

fox mulder created an issue. See original summary.

fox mulder’s picture

ritarshi_chakraborty’s picture

I tried the patch on #2 and it resolves the error.
But I think it will be a better approach if we normalize the empty value in submitForm.

ritarshi_chakraborty’s picture

StatusFileSize
new779 bytes
fox mulder’s picture

#4 doesn't solve the problem

kalash-j’s picture

Assigned: Unassigned » kalash-j
ritarshi_chakraborty’s picture

That's weird :(
I applied the changes and the error seems to get resolved.

kalash-j changed the visibility of the branch 3561441-Minimum_password_length to hidden.

kalash-j changed the visibility of the branch 3561441-Minimum_password_length to active.

kalash-j’s picture

Status: Active » Needs review
anurag_nagar’s picture

Status: Needs review » Reviewed & tested by the community

@kailash-j I have checked the MR and it seems to be working.

  • kalash-j committed 3b8e13ff on 2.x
    Issue #3561441 by kalash: Fixed the problem.
    
astonvictor’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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