Problem/Motivation

The anonymous user can never have different roles, so we don't need to add this cache tag.

Found this looking for something else - it seems to be added a lot by access policies to the static variation cache, so it may mean a bit less cacheablemetadata work hopefully.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3608738

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

catch created an issue. See original summary.

catch’s picture

I can only reproduce this being added a lot on Drupal 11.3, not main, so possibly something improved in the meantime.

Having said that, it also won't do any harm.

catch’s picture

Status: Active » Needs review

kristiaanvandeneynde’s picture

As discussed on Slack, this makes total sense. Depending on the scenario it might not improve things much, but not tagging stuff when you don't need to still beats tagging it for no reason.

Consider this RTBC, but awaiting test results.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Makes sense, I would have gone with the suggestion of a $cacheability variable too personally, but that's just personal preference.

  • godotislate committed b3351dd5 on main
    task: #3608738 Avoid adding user:0 cache tag in UserRoles cache context...

  • godotislate committed f7e2186d on 11.x
    task: #3608738 Avoid adding user:0 cache tag in UserRoles cache context...

  • godotislate committed d4fe6da2 on 11.4.x
    task: #3608738 Avoid adding user:0 cache tag in UserRoles cache context...
godotislate’s picture

Version: main » 11.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushedb3351dd to main, f7e2186 to 11.x, and d4fe6da to 11.4.x. Thanks!

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.