Deprecation errors if "Changes" left empty

Created on 2 July 2025, 4 months ago

Problem/Motivation

If you leave "Changes" empty when updating Ts & Cs, due to Xss::filterAdmin running on the empty string, if you are running PHP 8.1 or above, you get the errors:

Deprecated function: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Unicode::validateUtf8() (line 395 of core/lib/Drupal/Component/Utility/Unicode.php).

Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\Component\Utility\Xss::filter() (line 69 of core/lib/Drupal/Component/Utility/Xss.php).

Steps to reproduce

1. Update your terms of use with no changes
2. Go to the Ts & Cs page
3. Observe deprecation errors

Proposed resolution

Check if changes is empty before running the filter.

Remaining tasks

Fix the code.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom littlepixiez

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024