TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given

Created on 5 May 2025, 12 days ago

Problem/Motivation

Visiting the Manage Display page for a content type (/admin/structure/types/manage/[node]/display) causes a fatal error:

TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given...

Steps to reproduce

  1. Enable Display Suite (ds) module.
  2. Go to /admin/structure/types/manage/[your_content_type]/display.
  3. If a field has no field template set or the formatter is not recognized, you encounter the error.
  4. The page crashes with a TypeError.

Proposed resolution

Replace:

$summary[] = 'Field template: ' . Html::escape($field_function);

With:

$summary[] = 'Field template: ' . Html::escape((string) $field_function);

This ensures no fatal error occurs when $field_function is NULL.

πŸ› Bug report
Status

Active

Version

3.29

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States andysipple

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

Comments & Activities

Production build 0.71.5 2024