PHP error in views when adding fields

Created on 19 June 2025, 2 months ago

Problem/Motivation

Trying to add a field to a view based on meilisearch index does nothing and a PHP error is returned/logged on Drupal 11 instance.

The logs show the following error.

TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in /var/www/html/web/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 238 in Drupal\Component\Utility\Html::escape() (line 431 of /var/www/html/web/core/lib/Drupal/Component/Utility/Html.php).

Steps to reproduce

  1. Create a new view based on meilisearch index (View settings: Index {INDEX_NAME}) or edit existing view
  2. In the Fields section click Add button
  3. Nothing happens, the ajax request returns 500 response and an error message is displayed on top
  4. The logs show the php error described above

Proposed resolution

On investigating the issue, the problem lies in how the module handles special search api fields. In 🐛 Error when indexing special fields (search_api_*) Fixed we clone special fields as backend defined fields, however this is incorrect as special fields are not meant to be visible and/or added through UI.

Since the special fields do not hold any labels the cloned backend defined fields also contain no label and the error is thrown.

A quick fix would be to use empty string where NULL labels are returned however the underlying issue should be fixed and special fields should be handled properly.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇸🇮Slovenia bcizej

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