Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291583

[D7 PHP 8.1] str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in filter_xss()

$
0
0

Problem/Motivation

We are experiencing multiple deprecation warnings on PHP 8.1 in filter_xss() function:

Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in filter_xss() (line 1503 of /includes/common.inc).
Deprecated function: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in drupal_validate_utf8() (line 1936 of /includes/bootstrap.inc).

The first one is directly in filter_xss() and the second one is in drupal_validate_utf8() function which is called by filter_xss().

The problem is not the Drupal core itself, but some modules seems to be calling filter_xss() with null, which results in this warning. As @mfb pointed out in #3224299-54: [META] Make Drupal 7 core compatible with PHP 8.1, recently there was a fix in check_plain() function, which implemented the same sanitization to the input variable, see: #3254699: [D7 PHP 8.1] check_plain(): Passing null to parameter #1 check_plain() includes/bootstrap.inc, line 1907. According to this, I think we can make an exception also here and fix these two functions in Drupal core.

Steps to reproduce

These deprecation warnings were present on some ajax calls (related to admin views, or views ajax filters), but it needs more testing. I think there are lots of modules which does not sanitize variable sent to filter_xss(), so this is another argument to fix it in the core.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 291583

Trending Articles