Sorry, I'm a bit late with this and I'm not sure how relevant this issue is.
Anyway, when I updated from 2.1.0 to 2.1.2 I thought my settings would stay the same as they were. However, this was not the case with Google Consent mode. I had intentionally set it to v2 before and it changed to v1.
This happened because of the update hook
function cookieinformation_update_9201() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('cookieinformation.settings');
if ($config->get('enable_google_consent_mode')) {
$config->set('google_consent_mode', 'v1');
}
elseif($config->get('enable_google_consent_mode_v2')) {
$config->set('google_consent_mode', 'v2');
}
else {
$config->set('google_consent_mode', '');
}
It turns out my issue happened because I had checked both checkboxes v1 and v2 in the old version. The if block above seems to assume right away that if I have v1 enabled it will give me v1 in the future. I'm not a Google consent mode expert but I'd think it would be a bit more logical to check for v2 first? If you had both v1 and v2 enabled in the past, you would want to use only v2. So maybe change those around?
if ($config->get('enable_google_consent_mode_v2')) {
$config->set('google_consent_mode', 'v2');
}
elseif($config->get('enable_google_consent_mode')) {
$config->set('google_consent_mode', 'v1');
}
else {
$config->set('google_consent_mode', '');
}
What do you think?
| Comment | File | Size | Author |
|---|---|---|---|
| cookie_information_conf_changes_after_updating.png | 98.32 KB | hartsak |
Issue fork cookieinformation-3477206
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
heikkiy commentedHi @hartsak.
Thank you for the message. Yes, the old implementation for the settings was a bit confusing and we also mixed them a bit when we were trying to figure out how to support both v1 and v2. Sorry for the bad UX that originally caused this issue.
I think in the process we initially thought that people by default have been using v1 and we didn't want to suddenly switch the default to v2 without them acknowleding any other change they might need to do for example in the Cookie information template.
The change should be still be visible in the config that you see the correct v1 or v2 version so the change should be pretty easy to catch.
I am trying to think if you should in the future enforce v1 or v2 if both have been selected before.
Comment #4
heikkiy commentedComment #6
heikkiy commentedI think this change could be done for both the new 2.2.x and previous 2.1.x branches. I will make a MR for both.
Then we could release 2.1.5 and 2.2.1 with the small backward compatibility fix.
Comment #10
kekkisLGTM here too. On both MRs.
Comment #12
heikkiy commentedMerged to both 2.1.x and 2.2.x. Credited the fix to you.