Undefined variable $field_value in CustomValue processor

Created on 5 December 2023, 12 months ago
Updated 20 January 2024, 10 months ago

Problem/Motivation

I'm using the custom_value processor on my site. I just saw that if you forgot to set a value on a custom_value field in your index, it throws a warning error :
Warning : Undefined variable $field_value dans Drupal\search_api\Plugin\search_api\processor\CustomValue->addFieldValues() (/home/tmaquin/Bureau/drupalfactory/web/modules/contrib/search_api/src/Plugin/search_api/processor/CustomValue.php ligne 118)
I think this processor shouldn't throw errors even if you misconfigured your custom fields.

Proposed resolution

Could we juste replace in CustomValue the iteration by a empty function ?

if (!empty($field_value)) { $field->addValue($field_value); }
Instead of
if ($field_value !== '') { $field->addValue($field_value); }

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Plugins

Created by

πŸ‡«πŸ‡·France t.maquin

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

Comments & Activities

Production build 0.71.5 2024