Problem/Motivation
Once #2381217: Views should set cache tags on its render arrays, and bubble the output's cache tags to the cache items written to the Views output cache is in, we expose the full chain of cache tags for a view.
Beside from that we have quite a complex mechanism to calculate the cache contexts used by a view, by iterating over all plugins.
One central piece though is missing still, taking into about node access or other kind of access mechanisms.
Proposed resolution
- Allow views base tables to define view cache contexts. Core would probably just define
cache_context.node_view_grants
for node - Determine this information from entity types by default, so add an additional
ContentEntityType::getListCacheContexsts()
- Use that information both in views base tables as well as in list builder
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#33 | interdiff.txt | 2.03 KB | dawehner |
#33 | 2445743-33.patch | 20.29 KB | dawehner |
#24 | 2445743-23.patch | 20.14 KB | dawehner |
#24 | interdiff.txt | 771 bytes | dawehner |
#21 | 2445743-21.patch | 19.38 KB | dawehner |
Comments
Comment #1
dawehner.
Comment #2
Wim LeersComment #3
Wim Leers#2099137-66: Entity/field access and node grants not taken into account with core cache contexts contains an initial
EntityTypeInterface::getListCacheContexts()
implementation. I prefer getting just that part in first, since I expect us to get stuck on tricky Views aspects here, as usual :) If you know how to make this happen, feel free to take the interdiff in that patch and reuse it here when rolling a patch for Views!(I sadly don't know Views well enough to roll this patch, so I'm choosing to go for the other issue first because I do know how to make progress there.)
Comment #4
dawehnerNot sure whether actually anything from views <-> cache contexts worked.
Comment #6
dawehnerI guess some earlier test coverage would have been nice ;)
Comment #7
Wim LeersThe current patch doesn't apply cleanly anymore (but it does apply with
git apply -3
), so straight reroll. Please don't credit me.This patch works perfectly! I'd RTBC, but I have one important question and a minor one.
Why did this have to be moved? It's still at the display level though. Basically: I don't understand these config schemas and therefore don't understand why it's moved.
Oh heh… I guess this means that it never actually worked as expected?
Comment #8
Wim LeersOh, the IS also mentions
— which is indeed necessary. Do you want to do that in this issue, or in another?Comment #9
dawehnerWell, the reason is kinda simply, it used to be defined on the wrong place. It was placed under:
.
The actual code though places it in:
. (yes that is pseudocode, and yes, it never worked :))
It did not worked in multiple possible ways.
Let's do it.
Comment #10
Wim LeersWonderful — thank you!
Comment #11
Fabianx CreditAttribution: Fabianx commentedRTBC + 1
Comment #13
Wim Leers#2414539: Simplify schema definition for sequence broke this. Straight reroll. Please don't credit me.
Comment #14
alexpottThe issue has landed.
Comment #15
Wim LeersRight, yay! I'm happy to do this unless dawehner wants to roll it.
Comment #16
Wim LeersFixed those @todos.
Comment #18
Wim LeersComment #19
Fabianx CreditAttribution: Fabianx commentedBack to RTBC + 2, looks great!
Comment #20
dawehnerWorking on a reroll + expanding test coverage on the frontpage.
Comment #21
dawehnerThis seems to be all which is needed.
Comment #23
dawehnerFixed the remaining failures.
Comment #24
dawehnerFixed the remaining failures.
Comment #25
Fabianx CreditAttribution: Fabianx commentedOh, how nice to see your cache contexts, views :).
Back to RTBC!
Comment #26
Wim Leers:) This is why I already added cache contexts in #2381217: Views should set cache tags on its render arrays, and bubble the output's cache tags to the cache items written to the Views output cache — because that issue was chiefly about cache tags, but in spirit it was about bubbling in general. So I used cache context merging already there. That's why #21 + #24 are both single-line test fixes. Great to see it come together like that :)
Comment #27
alexpottAdded missing code docblocks.
This issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed a87aff8 and pushed to 8.0.x. Thanks!
Comment #30
alexpottComment #33
dawehnerOh damn, a commit conflict. This is a fix.
Comment #34
Fabianx CreditAttribution: Fabianx commentedBack to RTBC, ouch on the conflict. Do we have a tag for potentially conflicting things?
Comment #35
alexpottLet's try again. Committed 0fe1e7d and pushed to 8.0.x. Thanks!
This type of commit conflict is kind of avoidable unless patch author's decide to postpone one of the issues on the other or the rtbc retest gets in first. Which is one of the problems with a long rtbc queue.
Comment #37
Wim LeersThis unblocked #2381277: Make Views use render caching and remove Views' own "output caching" and #2099137: Entity/field access and node grants not taken into account with core cache contexts, thanks!
#34: we have the "Avoid commit conflicts" tag, but we generally use it only for patches that are very painful to reroll.