Closed (fixed)
Project:
Drupal core
Version:
8.6.x-dev
Component:
workspaces.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
4 Jan 2018 at 13:10 UTC
Updated:
24 Jul 2018 at 12:31 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
fabianx commentedYes, it should.
The reason why there is a getCacheableMetadata() method on CacheContexts is that those are living in a kind of hierarchy, e.g. user permissions is a good thing. You can cache that per user / session, but if you remove it you need to add the cache tags of the user.roles so if those change the permissions hash is updated.
e.g. think of it like when the cache context needs to be cached by something else. (e.g. in Varnish per url or per user session).
Comment #3
amateescu commentedComment #4
amateescu commented@Fabianx, thanks for the detailed explanation. Given your last example and the fact that the active workspace will always end up in the user's session (e.g. workspaces do no make sense for anonymous users), I think this patch should be enough.
Comment #5
amateescu commentedComment #6
timmillwoodIn the future we may add more active workspace negotiators, and contrib (such as Relaxed module) will also add these. Therefore, would it make sense for the negotiators to be able to set the cache context? In other words, should we add a
getCacheContexts()method the negotiators?Comment #7
fabianx commented#6 It probably makes sense - yes.
The PR for now looks good to me however.
Comment #8
alexpottI can't see a reason why we would have test coverage for this?
Comment #9
amateescu commentedAdded a couple of assertions to check that the cache context used by
WorkspaceCacheContextis emitted properly.Comment #10
amateescu commentedComment #11
timmillwoodLooks good.
Comment #12
wim leers👌
Comment #13
plachSaving credit
Comment #14
plachCommitted 7a61525 and pushed to 8.6.x. Thanks!
Comment #17
amateescu commentedFix component following module rename.