Empty geocoding results aren't always cached

Created on 10 July 2018, almost 6 years ago
Updated 30 October 2023, 8 months ago

The geocoder widget makes it's own geocoding call, with its own wrapping cache get/set call. Even empty results get passed to geocoder_cache_set(), so the 'Cache empty results' setting will be respected.
But direct calls to the geocoder() API function (e.g. from other places, like the geofield module's views handler), won't respect that setting, because the geocoder() returns NULL before setting cache if an exception is thrown during geocoding. It shouldn't return early.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom james.williams

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.

  • πŸ‡ΈπŸ‡°Slovakia poker10

    Thanks for working on this.

    Are we sure we want to cache the results on exceptions? Exceptions can be temporary and could happen in special cases / network errors or similar:

    $msg = t('HTTP request to Bing API failed.\nCode: @code\nError: @error', $args);
    throw new Exception($msg);
    

    Does this have any benefit / drawbacks?

    Otherwise, if the call $geometry = call_user_func($processor['callback'], $data, $options); returns NULL/empty results, it will make its way to the geocoder_cache_set(), so I think this works correctly. Only if there is an exeption the result is not cached. Thanks!

Production build 0.69.0 2024