No description causes deprecation warning

Created on 28 September 2025, 13 days ago

Problem/Motivation

After updating from 2.2.0 to 2.2.1 I see the following errors when a page is first loaded after clearing caches:

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).
Drupal\Component\Utility\Unicode::validateUtf8() (Line: 65)
Drupal\Component\Utility\Xss::filter() (Line: 366)
Drupal\tooltip_taxonomy\Services\TooltipManager->addVocabularyReplacement() (Line: 249)
Drupal\tooltip_taxonomy\Services\TooltipManager->addTooltip() (Line: 71)
tooltip_taxonomy_entity_display_build_alter() (Line: 552)
Drupal\Core\Extension\ModuleHandler->alter() (Line: 289)
<snip>

The error is present for every taxonomy term that has no description. Looks like it's caused by this change in MR17:
From:

$des = strip_tags($term->get('description')->value, $allowed_html_tags);

To:

$des = Xss::filter($term->get('description')->value, $allowed_tags_array);

Steps to reproduce

  1. Create a taxonomy term with no description.
  2. Create a taxonomy tooltip referring to the above term type.
  3. Add the term to a page.
  4. Clear all caches.
  5. Load the page and observe a deprecation warning for each instance of a term with no description.

Proposed resolution

Check for description first, eg, add this before the Xss::filter line:

if ($term->get('description')->isEmpty()) {
  continue;
}
🐛 Bug report
Status

Active

Version

2.2

Component

Code

Created by

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024