Problem/Motivation
The GeoIP popup in language_switcher_dialog_geoip can fail to appear for anonymous visitors, even when Smart IP is enabled and geolocation is otherwise working.
The cause is that GeoIpDialogController::content() performs a fresh raw lookup with SmartIp::query() instead of using Smart IP's normal resolved location flow.
That bypasses:
- the stored Smart IP location
SmartIp::updateUserLocation()- Smart IP fallback enrichment such as
userLocationFallback()
As a result, the HTMX popup request can return 204 No Content when the direct query has no countryCode, even though Smart IP may already have resolved the visitor's location through its standard flow.
Steps to reproduce
- Enable
language_switcher_dialog,language_switcher_dialog_geoip, andsmart_ip. - Configure Smart IP to geolocate anonymous users.
- Open the site as an anonymous user in a fresh/private browser session.
- Visit a localized page, for example
/fr/testpage. - Observe the HTMX request to
/language-switcher-dialog/geoip?destination=....
Actual result: the endpoint can return 204, so the popup is not shown.
Expected result: the popup should use Smart IP's resolved location and appear when a country can be determined.
Proposed resolution
Update GeoIpDialogController to use Smart IP's location service / stored location flow instead of calling SmartIp::query() directly.
For example, retrieve the resolved location from the Smart IP location service via getData(TRUE) and use that data to determine countryCode.
This makes the popup behavior consistent with the rest of Smart IP and avoids false 204 responses for anonymous users.
Remaining tasks
- Patch
GeoIpDialogControllerto use the Smart IP location service. - Add or update automated test coverage for the stored-location path.
- Verify the popup appears correctly for anonymous visitors in a fresh session.
User interface changes
None in terms of new UI. This fixes cases where the existing GeoIP popup fails to appear.
API changes
None expected.
Data model changes
None.
Issue fork language_switcher_dialog-3607957
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 #4
svendecabooter