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
- Create a new view based on meilisearch index (View settings: Index {INDEX_NAME}) or edit existing view
- In the Fields section click Add button
- Nothing happens, the ajax request returns 500 response and an error message is displayed on top
- 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 #3396022: Error when indexing special fields (search_api_*) 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.
Issue fork search_api_meilisearch-3530985
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
bcizej commentedPR created
Comment #4
Anonymous (not verified) commentedI've checked this branch locally with clean install of D11 and tested this by creating a new view and then applying sorting on the indexed attributes. I've also reviewed code in the MR and everything seems to be ok. Marking this as RTBC.
Comment #6
bcizej commented