TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given

Created on 31 July 2024, 10 months ago

Problem/Motivation

Since PHP 8.1 has deprecating passing NULLs to many string manipulating functions and hence it throws TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given when we save password length form.

Steps to reproduce

1. install site using Drupal 11 ex : ./vendor/bin/drush si
2. log in to site
3. enable module using ./vendor/bin/drush en password_policy_blacklist password_policy_character_types password_policy_characters password_policy_consecutive password_policy_delay password_policy_history password_policy_length password_policy_username
4. Then go to /admin/config/security/password-policy and create a new policy and click save
5. In the Add constraint section add password character type and click save
6. Then add password character length and keep values to default and then click save and see the popup is not getting closed.
7. go to admin/reports/dblog and check the logs and you will see error

TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given

Proposed resolution

1. go to PasswordLength.php and verify validateConfigurationForm why we are getting null value and replace it with empty.

🐛 Bug report
Status

Closed: duplicate

Version

4.0

Component

Code

Created by

🇮🇳India deepakkm

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

Comments & Activities

Production build 0.71.5 2024