Problem/Motivation

The SearchApiNumeric ViewsField plugin init method does not handle correctly every situations. Works well for Plural settings are not saved for custom fields declared with mapping to search_api_numeric.

Steps to reproduce

  • Create a custom field extending IntegerItem
  • Subscribe to SearchApiEvents::MAPPING_VIEWS_FIELD_HANDLERS to map it to search_api_numeric
  • Add the field to a search api view
  • Enable format plural and add singular and plural strings
  • Save options
  • options are not saved properly

Proposed resolution

The condition should check the format_plural_values is not empty instead of checking if it is set.
Tested with indexed field, entity discovered field and computed field.

Issue fork search_api-3558388

Command icon 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

mattlc created an issue. See original summary.

drunken monkey’s picture

Assigned: mattlc » Unassigned
Status: Active » Fixed

Thanks a lot for reporting this!
I haven’t completely gone through your steps to reproduce but it does seem quite obvious that this check is pretty useless when we define the 'format_plural_values' option ourselves with default value [].
For this reason, I also think this doesn‘t really need test coverage.

So, merged.
Thanks again!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • drunken monkey committed 9b7c54af on 8.x-1.x authored by mattlc
    [#3558388] fix: Fixed saving of “Format plural” settings in numeric...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.