Problem/Motivation

Adding as bug based on https://www.drupal.org/project/eu_cookie_compliance/issues/3109907
When using categories and using "save preferences"/"accept all cookies" option instead of the standard "accept" selecting zero categories does not count as not consenting.

Steps to reproduce

Use cookie categories
Select 'Replace the Agree button with "Save preferences" and "Accept all categories" buttons.' option
Make sure "fix first", etc isn't checked
Click "save preferences" on the popup with no categories selected.
The state is stored as 2.

Proposed resolution

When saving preferences with no categories selected, treat it the same as withdrawing consent.

User interface changes

Clicking "save preferences" will trigger the withdrawAction, thus refresh the page and show the popup again.

Comments

Grayle created an issue. See original summary.

grayle’s picture

D8 patch

grayle’s picture

Status: Active » Needs review
StatusFileSize
new635 bytes

D7 patch

svenryen’s picture

Awesome, thanks! Will have a look today or tomorrow.

grayle’s picture

Assuming this (and the original patch's) approach is correct. It basically forces people to pick a category, but declining all categories (assuming they're all optional, which is itself probably an edge case, you'll usually always have a "functional" category as required) is, I think, a valid option.

Currently, when not using categories, you can decline cookies and the status gets set to '0' (correct me if I'm wrong here).
When using categories, if you select no categories, the status gets set to 'null', meaning the popup will show up again and again until they accept a category. I think it should probably simply set the status to '0' as well, to match the standard decline option.

svenryen’s picture

OK. Is that reflected in your patch or do you need to update it? The use of `null` and `0` sure is a bit confusing, we should do better in 2.x :)

grayle’s picture

New patches, will set status to 0 when declining cookies by way of not selecting any categories.

Talked to legal, and you don't have to add your functional cookies as a required category, or at all, so the case where all categories are optional and functional cookies are implied is real.

And this approach works for all cases, anyway. I believe it's incorrect to set the state to null when not agreeing to any categories. 0 seems correct.

Has no impact on existing sites, except to make it better. Users who keep refusing cookies on each page load now will only have to do so once more after this gets in.

The last submitted patch, 7: D8.3168910.save-preferences-no-categories.6.patch, failed testing. View results

svenryen’s picture

I have a few questions. Have you tested this without categories (consent by default)? And will it not break existing functionality for the banner with no categories when you remove euCookieComplianceLoadScripts() on line 402?

grayle’s picture

I believe the random euCookieComplianceLoadScripts() was a bug/random copy paste error. Seeing as the loadCategoryScripts method uses that function as well to load scripts for the selected categories I don't see the point in calling it before then with no parameters at all.

I haven't tested it with non-category consent, however savePreferences only gets attached when you're using cookie categories (where I removed the euCookieComplianceLoadScripts()) and the change in the other method should already be wrapped in a check so it only runs when the banner is using categories.

But it can't hurt to doublecheck.

svenryen’s picture

Thanks for clarifying that. I'll merge this tonight then.

svenryen’s picture

-

svenryen’s picture

-

svenryen’s picture

Status: Needs review » Reviewed & tested by the community

Works great!

  • Grayle authored b207d90 on 7.x-1.x
    Issue #3168910 by Grayle, svenryen: Saving preferences without any...

  • Grayle authored 8399497 on 8.x-1.x
    Issue #3168910 by Grayle, svenryen: Saving preferences without any...
svenryen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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