_form_validate sends null to drupal_strlen triggering deprecation notice

Created on 23 May 2023, about 1 year ago
Updated 17 June 2024, 8 days ago

Problem/Motivation

Since PHP 8.1, Deprecation notices are ensuring type safety on more standard functions.
This includes mb_strlen, called in drupal_strlen.
If NULL is passed to drupal_strlen, the following deprecation notice will triggers:

mb_strlen() expects parameter 1 to be string, array given in .../drupal/includes/unicode.inc on line 482.

Steps to reproduce

When $elements['#value'] is NULL, and $elements['#maxlength'] is set, on PHP 8.1, the deprecation notice will triggers during form validation

Proposed resolution

Added an isset check before calling drupal_strlen.
This function make a lot of isset check above and below, so having a null value here seems expectable.
Prevent that null value to be passed by drupal_strlen.

πŸ› Bug report
Status

Fixed

Version

7.0 ⚰️

Component
FormΒ  β†’

Last updated about 7 hours ago

Created by

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024