Error message

You need to log in or create an account to access this page.

Problem/Motivation

geocoder-php is upgrading the Mapbox provider to the Mapbox Geocoding API v6 as version 2.0.0 (PR #1274). Two changes break the module's mapbox plugin (at 25d27ea):

  • Constructor argument 4 changed type. v5: string $geocodingMode (mapbox.places or mapbox.places-permanent). v6: bool $permanent = false — there is one endpoint plus a permanent request parameter (v6 constructor, Mapbox docs).
  • fuzzy_match no longer exists. v6 removed fuzzy matching; the closest option is the autocomplete parameter (provider CHANGELOG 2.0.0).

The bug. This module passes the plugin annotation's arguments positionally to the handler's constructor (getHandler()ReflectionClass::newInstanceArgs(); ProviderUsingHandlerBase.php at 25d27ea). The plugin declares "geocodingMode" = "mapbox.places", so with provider 2.x that string lands in bool $permanent. The call site is not strict-typed, so PHP coerces any non-empty string to TRUE (coercion rules): every geocode request silently sends permanent=true, switching to permanent result storage — which requires a credit card or active enterprise contract with Mapbox (Mapbox docs).

Steps to reproduce

  1. On a site with a configured Mapbox provider (geocoder.geocoder_provider.mapbox, plugin: mapbox, default options), run composer require geocoder-php/mapbox-provider:^2.0 (once 2.0.0 is released from the PR above).
  2. Geocode any address through the module.
  3. Inspect the outgoing request to https://api.mapbox.com/search/geocode/v6/forward: the query string contains permanent=true even though permanent storage was never configured.

Proposed resolution

Update the Mapbox plugin in place for provider 2.0.0:

  1. src/Plugin/Geocoder/Provider/Mapbox.php (at 25d27ea):
    • Annotation: replace "geocodingMode" = "mapbox.places" with "permanent" = false.
    • doGeocode(): drop withData('fuzzy_match', ...) (optionally expose the v6 autocomplete parameter instead).
    • defaultConfiguration(): remove 'fuzzy_match' => FALSE.
    • buildConfigurationForm() / submitConfigurationForm(): remove the fuzzy_match field (optionally add an autocomplete checkbox).
    • The location_type textfield needs no change: its comma-separated list maps directly to the v6 types parameter (Mapbox docs).
  2. config/schema/geocoder.schema.yml (at 25d27ea), geocoder_provider.configuration.mapbox: remove geocodingMode and fuzzy_match; add permanent (boolean).
  3. Config update (hook_update_N in geocoder.module) for geocoder.geocoder_provider.* entities with plugin: mapbox: configuration.geocodingMode equal to mapbox.places-permanent becomes configuration.permanent: true, otherwise false; unset geocodingMode and fuzzy_match.
  4. composer.json (at 25d27ea): require-dev geocoder-php/mapbox-provider ^1.0^2.0; consider a conflict on geocoder-php/mapbox-provider <2.0 so the required provider upgrade is explicit at install time.

An in-place update matches how this module has handled provider changes before: the geocodingMode option itself was added in place when Mapbox split its temporary/permanent endpoints (#3301383), the Addok endpoint move was an in-place default update (#3561519), and willdurand/geocoder 4→5 was a composer-only change (#3510823). Distinct plugin ids have only ever been used for different services (e.g. openstreetmap, azuremaps), never for an API version of the same service.

Known consequence: the updated plugin requires provider 2.x — the new boolean default cannot be coerced to the old string $geocodingMode parameter (bool → string is a TypeError in both strict and non-strict mode). This is covered by the release note below.

Remaining tasks

  • Implement the changes in Proposed resolution.
  • Add/update plugin tests covering the new constructor argument.
  • Review config update and release note.

User interface changes

Provider configuration form: the "Geocoding Mode" textfield and "Fuzzy match" checkbox are removed; a "Permanent" checkbox is added (plus an "Autocomplete" checkbox if that option is exposed).

Introduced terminology

permanent — the v6 request parameter selecting permanent vs. temporary result storage (Mapbox docs). Replaces the v5 mapbox.places-permanent geocoding mode.

API changes

  • The mapbox plugin's @GeocoderProvider annotation: the arguments key geocodingMode (string) is replaced by permanent (boolean, default false).
  • doGeocode() no longer sets fuzzy_match query data on the GeocodeQuery.
  • Everything else is unchanged: Geocoder::geocode() at 25d27ea already accepts GeocodeQuery|string and routes GeocodeQuery calls to the plugin's geocodeQuery(), so callers passing custom query data (e.g. v6 structured input fields) are unaffected.

Data model changes

The config update in Proposed resolution migrates geocoder.geocoder_provider.* entities with plugin: mapbox. No changes to content entities.

Release notes snippet

The Mapbox provider plugin now targets geocoder-php/mapbox-provider 2.0.0 (Mapbox Geocoding API v6) and requires it. The geocodingMode and fuzzy_match configuration options are replaced by a permanent option; a config update migrates existing Mapbox provider configurations. Sites that must stay on the v5 API should keep geocoder-php/mapbox-provider at 1.x and the geocoder module at a pre-v6 release.

Issue fork geocoder-3620309

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

davidwbarratt created an issue. See original summary.

davidwbarratt’s picture

Issue summary: View changes