Passing NULL to Xss::filterAdmin($term->changes); in legal_display_changes()

Created on 11 August 2023, over 1 year ago
Updated 31 May 2024, 7 months ago

Problem/Motivation

When terms version changes but not changes are added $term->changes comes back as NULL which is then passed to `$changes = Xss::filterAdmin($term->changes);`

Steps to reproduce

  • Create Terms
  • Have test user accept terms
  • Change terms so the terms version updates
  • Do not alter "Explain changes: Changes"
  • Log in with the test user again
  • User will need to accept again but no changes will be available to show the diff
  • Error is thrown
Deprecated function: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Unicode::validateUtf8() (line 477 of core/lib/Drupal/Component/Utility/Unicode.php).
Drupal\Component\Utility\Unicode::validateUtf8(NULL) (Line: 65)
Drupal\Component\Utility\Xss::filter(NULL, Array) (Line: 123)
Drupal\Component\Utility\Xss::filterAdmin(NULL) (Line: 758)
legal_display_changes(Array, '62') (Line: 145)

Proposed resolution

Check for NULL value for $term->changes.

$changes = Xss::filterAdmin($term->changes);

Becomes:
$changes = !empty($term->changes) ? Xss::filterAdmin($term->changes) : NULL;

Remaining tasks

Patch and review.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇨🇦Canada sleepingmonk Vancouver Island 🇨🇦

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

Comments & Activities

Production build 0.71.5 2024