See the parent issue. Here's the same change for 8.x.

It shouldn't be possible to choose both "Display only for visitors from EU Countries" options, and the JS-version needs a better explanation.

This patch makes the selector a set of radio buttons, and it's clarified that the JS version should be used in all situations where caching is enabled or set up.

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

svenryen created an issue. See original summary.

john_b’s picture

I fear that the D7 issue in #3261155: We sometimes hit the cache before getting geographic location may affect D8/9 too. In other words, the non-JS is unreliable. I mentioned this in passing in an unrelated issue.

For geolocation to be reliable we have got have a session for every visit. I can load the site in Austria, where smart_ip correctly detects my location, get a 200, with no session cookie or session storage being set in the browser. I am using smart_ip. There is no server caching--I am not using a VPN or Varnish, and the server is my own basic Apache + php-fpm setup. I have just tested this in Edge.

Arguably the problem is with smart_ip. In testing on D7, session_cache module did not fix the problem. Anyway, it does not exist for D8/9.

I do not know whether geolocation can fail if a session is set.

Another argument is that is undesirable for EU Cookie Compliance to rely on setting a session for anonymous, so there would be case for removing the non-JS option even if it were working reliable.

svenryen’s picture

@John_B: I tested this from my localhost as Anonymous as well as on a mobile phone using VPN from both a non-GDPR and GDPR country. It seemed to work really well based on my testing and did resolve the issue that was seen when the patch wasn't added.

I do not know whether geolocation can fail if a session is set.

I would expect geolocation to always work when a session is set. Do you have any steps I can use to make geolocation fail when a session is set?

I'll re-test again from TWO phones today (both as anonymous and with a session) to make sure the patch still resolves the issue.

john_b’s picture

My main point was that Geolocation was failing in my test and no session cookie (or EU Cookie Consent cookie) was seen in Edge dev tools.

The question about whether it could also fail when a session is set was not relevant, just me thinking alound.

I have just reproduced this in Chrome.

STEPS:
I am in Austria, no VPN, and an IP which Max-mind identifies correctly according to the smart_ip test form. D9.3.9, Apache 2.4.53, PHP 8.1, no reverse proxy.
Set EU Cookie Compliance to EU Only and save.
Initially the banner appears on page load.
Load the site a few times so the cache is warm.
Clear all cookies and cache in Chrome.
Enter the URL in the address bar and hit "Enter".
Check in Network tab that we are getting a 200 on the HTML doc.
No banner appears. No Drupal session cookie (or other cookie) is set. No Session storage is set.

svenryen’s picture

Set EU Cookie Compliance to EU Only and save.

Is this the JS version or the non-JS version you're using? Is the Smart IP module enabled and what are its settings?
Do you see he same behavior with D7 and D8?
Did you apply the patch from the issue fork?

I'm not able to reproduce your scenario when I use this patch and the option that now's called "Use JavaScript to determine if the visitor is in a country where GDPR applies".

john_b’s picture

This is the non-JS version, with the JS version unset. Behaviour is same on D7.

I did not apply the patch, which appears only to affect the settings form.

smart_ip is using GeoIP Maxmind Precision, Country-level. "Save user's location details upon creation" and "Don't save location details of visitors from GDPR countries" are on (but probably not relevant as I am only testing on anonymous). Debug is off.

The JS version works.

Happy to do a screen share so you can see the bug yourself.

svenryen’s picture

Since you're using the non-JS version, can I assume there's no caching involved? No browser cache, no external cache and no cache in the Drupal database for the page in question?

svenryen’s picture

Here are the steps I've taken to try to reproduce:

1) Set the option to what used to be called "Only display banner in EU countries" (non-JS)
2) Disable Page cache and Dynamic cache modules (and any other caching you may have enabled)
3) Turn my phone to 4G and enable VPN with a US IP address
4) Clear all cookies
5) Access the test IP and load the page => notice there's no banner
6) Set the VPN to a European IP
7) Clear all cookies
8) Access the test IP and load the page => notice there's now a banner showing

If your steps gives a different result, I would be happy to go on a screen share with you to learn what I've missed.

john_b’s picture

Status: Needs review » Reviewed & tested by the community

Sorry, I made a mistake. Somehow I was expecting the non-JS version to work with caching enabled on D8.

  • svenryen committed 29a03fe on 8.x-1.x
    Issue #3274594 by svenryen, John_B: 8.x: We sometimes hit the cache...
svenryen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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