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

  1. Enable language_switcher_dialog, language_switcher_dialog_geoip, and smart_ip.
  2. Configure Smart IP to geolocate anonymous users.
  3. Open the site as an anonymous user in a fresh/private browser session.
  4. Visit a localized page, for example /fr/testpage.
  5. 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 GeoIpDialogController to 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.

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

svendecabooter created an issue. See original summary.

  • svendecabooter committed 1a303efa on 1.0.x
    fix: #3607957 GeoIP popup controller bypasses Smart IP stored location...
svendecabooter’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.