Use of deprecated function substr_count() in Drupal 9 codebase: Passing null to parameter #1

Created on 9 May 2023, over 1 year ago
Updated 27 September 2023, about 1 year ago

Problem/Motivation

I have a Drupal site 9.4.8 and when I visit the /admin/config/development/reroute_email form I got this erorr

Deprecated function: substr_count(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\reroute_email\Form\SettingsForm::textareaRowsValue() (line 245 of modules/contrib/reroute_email/src/Form/SettingsForm.php).

The `substr_count()` function is currently used in Drupal 9 codebase, but it will be removed in Drupal 10. This means that any code that relies on `substr_count()` will not be compatible with Drupal 10 and beyond.

Steps to reproduce

1. Install Drupal 9
2. Use the `substr_count()` function in your code
3. Attempt to upgrade to Drupal 10 or visit /admin/config/development/reroute_email

Proposed resolution

The `substr_count()` function should be replaced with the `mb_substr_count()` function, which is a multibyte-safe version of `substr_count()`. This change will ensure that code is compatible with Drupal 10 and beyond.

Remaining tasks

The `substr_count()` function should be identified in the Drupal 9 codebase, and replaced with the `mb_substr_count()` function. Any affected contrib or custom modules should also be updated.

User interface changes

None.

API changes

The `substr_count()` function will be replaced with `mb_substr_count()`, which is a multibyte-safe version of the same function.

Data model changes

None.

๐Ÿ› Bug report
Status

Fixed

Version

2.2

Component

Code

Created by

๐Ÿ‡ฏ๐Ÿ‡ดJordan mohammad-fayoumi Amman

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

Comments & Activities

Production build 0.71.5 2024