Solarium insists distances be integers and search_api_solr casts them as floats

Created on 23 February 2023, over 1 year ago
Updated 15 June 2023, over 1 year ago

Respect the submission guidelines above! Drupal.org issue forks cause additional work for the project maintainer!

Setup

  • Solr version:7.7
  • Drupal Core version:9.5.3
  • Search API version: 1.28
  • Search API Solr version: 4.2.10
  • Configured Solr Connector: Hosted Solr & Pantheon

Issue

The solarium/solarium package casts the distance you pass to the Spatial object as an integer. https://github.com/solariumphp/solarium/blob/master/src/Component/Spatia...

But this module casts it as a float:
https://git.drupalcode.org/project/search_api_solr/-/blob/4.x/src/Plugin...

This leads to a warning (for me at 16.09 km = 10 miles):
Deprecated: Implicit conversion from float 16.09 to int loses precision in /Users/mariafisher/Sites/lvhn/vendor/solarium/solarium/src/Component/Spatial.php on line 59

Hiding the warning should be relatively easy (convert to an int instead of a float) but the better solution would probably be something like ensuring numbers are integers in the UI and doing some kind of update hook for existing values...

Or making the argument that Solarium should support floats?

πŸ› Bug report
Status

Fixed

Version

4.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mariacha1

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024