PHP 8.1: Deprecated function: preg_replace(): Passing null to parameter #3

Created on 9 November 2023, 8 months ago
Updated 10 November 2023, 8 months ago

Problem/Motivation

3357171 fix, Introduced the following deprecation, in the edge case there are no words to count:

Deprecated function: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\node_read_time\Calculate\ReadingTime->calculateReadingTime() (line 178 of modules/contrib/node_read_time/src/Calculate/ReadingTime.php).
Drupal\node_read_time\Calculate\ReadingTime->calculateReadingTime() (Line: 76)

Steps to reproduce

Use node read time for instance with the computed field for a given content type, create a content with only title set and the deprecation is thrown.

Proposed resolution

Check that words property is not empty.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡΅πŸ‡ΉPortugal joao.ramos

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

Comments & Activities

Production build 0.69.0 2024