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.placesormapbox.places-permanent). v6:bool $permanent = false— there is one endpoint plus apermanentrequest parameter (v6 constructor, Mapbox docs). fuzzy_matchno longer exists. v6 removed fuzzy matching; the closest option is theautocompleteparameter (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
- On a site with a configured Mapbox provider (
geocoder.geocoder_provider.mapbox,plugin: mapbox, default options), runcomposer require geocoder-php/mapbox-provider:^2.0(once 2.0.0 is released from the PR above). - Geocode any address through the module.
- Inspect the outgoing request to
https://api.mapbox.com/search/geocode/v6/forward: the query string containspermanent=trueeven though permanent storage was never configured.
Proposed resolution
Update the Mapbox plugin in place for provider 2.0.0:
- src/Plugin/Geocoder/Provider/Mapbox.php (at 25d27ea):
- Annotation: replace
"geocodingMode" = "mapbox.places"with"permanent" = false. doGeocode(): dropwithData('fuzzy_match', ...)(optionally expose the v6autocompleteparameter instead).defaultConfiguration(): remove'fuzzy_match' => FALSE.buildConfigurationForm()/submitConfigurationForm(): remove the fuzzy_match field (optionally add an autocomplete checkbox).- The
location_typetextfield needs no change: its comma-separated list maps directly to the v6typesparameter (Mapbox docs).
- Annotation: replace
- config/schema/geocoder.schema.yml (at 25d27ea),
geocoder_provider.configuration.mapbox: removegeocodingModeandfuzzy_match; addpermanent(boolean). - Config update (
hook_update_Ningeocoder.module) forgeocoder.geocoder_provider.*entities withplugin: mapbox:configuration.geocodingModeequal tomapbox.places-permanentbecomesconfiguration.permanent: true, otherwisefalse; unsetgeocodingModeandfuzzy_match. - composer.json (at 25d27ea):
require-devgeocoder-php/mapbox-provider^1.0→^2.0; consider aconflictongeocoder-php/mapbox-provider<2.0so 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
mapboxplugin's@GeocoderProviderannotation: theargumentskeygeocodingMode(string) is replaced bypermanent(boolean, defaultfalse). doGeocode()no longer setsfuzzy_matchquery data on theGeocodeQuery.- Everything else is unchanged: Geocoder::geocode() at 25d27ea already accepts
GeocodeQuery|stringand routesGeocodeQuerycalls to the plugin'sgeocodeQuery(), 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
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
Comment #2
davidwbarratt commented