Needs work
Project:
Drupal core
Version:
main
Component:
entity system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 May 2017 at 20:32 UTC
Updated:
19 Jun 2026 at 16:12 UTC
Jump to comment: Most recent
Comments
Comment #2
berdirCan't we just invalidate the main entity cache tag when this happens? We might clear caches that we wouldn't have to, but there are also some interesting special cases, like deleting the only non-default revision and the impact of that (e.g. visibility of the revisions local task)
Comment #9
jibranOver in #2730631: Upcast node and node_revision parameters of node revision routes a block is added to the page which shows nid and vid based on the node_revision you are viewing. I had to add max-age 0 because there is no node revision tag I can add to the page.
Also
\Drupal\node\Controller\NodeController::revisionShowhasunset($page['nodes'][$node->id()]['#cache']);which can be removed if we fix this issue.Comment #10
berdir@jibran: The short answer to that is: No.
The longer answer is that the solution for both of those two things isn't cache tags, it is cache contexts in one case and cache keys in the other.
Cache tags are for invalidation. So the only thing this issue would help with is invalidating cached things, but that doesn't solve either of your problems. And revision cache tags are also only an optimization, those things already have the the node id cache tag, we'd just invalidate things for all revisions of a node.
The block needs cache contexts, because different versions of the same block could exist at the "same" time, without any invalidation happening. I would kind of expect that this does work, because if the block depends on plugin context, then the node it receives should have the route cache context, and that is different for each revision. Will try to have a closer look at that.
And the reason the cache *keys* are unset is because the keys would be the same for all revisions of the node, not the specific one you're looking at. So we could just add a revision id instead of removing it completely right now and it would just work. But the reason we don't do that is that it is most likely not worth to cache, viewing a revision is in almost all scenarios a rare action that only users with access to that do. The chance for a cache hit on a rendered node revision is very low, so we'd just fill up cache space.
Comment #19
mstrelan commentedI agree with @berdir in #2. Have started an MR to do this when revisions are deleted.
Should this be reclassified as a bug? Here are steps to reproduce, there is likely a simpler way to reproduce this though.
Comment #20
berdirThe current MR is the same as #2945928: Cache is not invalidated when deleting a revision see my comment there, I think we could close this as a duplicate.
I also partially changed my opinion as we already have a cache tag for revisions that we use invalidate in some cases, so things changed a bit since 2017.
Comment #22
prudloff commentedI think we should keep #2945928: Cache is not invalidated when deleting a revision because it has tests and the MR here does not have any.
(We should of course transfer credits.)