Synonyms processor text field error

Created on 25 August 2023, about 1 year ago
Updated 30 August 2023, about 1 year ago

Problem/Motivation

When saving an empty synonyms text field the code still tries to prepare synonyms. This causes:

Warning: Undefined array key 1 in Drupal\search_api_meilisearch\Plugin\search_api\processor\Synonyms->prepareSynonyms() (line 246 of modules/contrib/search_api_meilisearch/src/Plugin/search_api/processor/Synonyms.php).

The code still resets synonyms on meilisearch and returns the correct status "Synonyms were successfully deleted."

Steps to reproduce

  1. Install and enable the module
  2. Add a server and configure an index with fields that can contain synonyms.
  3. Under Processors enable Synonyms and click Save

Proposed resolution

Depending on what the desired functionality is, there are two options I see.

  1. Add a check to see if the synonyms field is correctly formatted before preparing and resetting if it's empty. If the desired functionality is to reset synonyms when the text field is empty.
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024