Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
menu system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Sep 2015 at 14:40 UTC
Updated:
16 Feb 2025 at 06:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
vijaycs85Comment #3
berdirI really think we should just clear the render cache when a new module is installed and remove block_install().
Comment #4
swentel commentedClearing at module install sounds logical to me as well.
Comment #6
berdirYou probably want the same logic and clear the tag.
I'm guessing what you're running into in that test fail is smart cache which afaik uses a separate bin.
Comment #7
vijaycs85sorry, I wasn't very clear explaining the issue summary. The problem isn't when you enable content_translation module. It's when you try to enable translation for different components at admin/config/regional/content-language
Comment #9
rodrigoaguileraI don't understand why we are deleting that hook_install.
Here is a patch with the same logic but for the form we are interested.
Comment #10
andypostIs this still repeatable?
Comment #11
rodrigoaguileraYes, as of yesterday HEAD I was able to reproduce the bug.
I will try to write the test at the drupalcon sprint.
Comment #12
rodrigoaguileraHere is the patch with the failing test.
Comment #15
rodrigoaguileraThe test only patch had a wrong file numbering.
Here is the complete patch.
Comment #16
rodrigoaguileraComment #17
wim leersThe latest patch has lost the hunk that removes
block.install. See earlier patche.sThis is wrong. This only invalidates the default render cache bin. Any cache bin can be used for render caching.
You must instead invalidate the
'rendered'cache tag.Comment #18
rodrigoaguileraI understood that the hook_install was out of scope for this issue. I don't know how it fits the proposed resolution because the cache stall doesn't happen on any module install but when changing translation settings.
Here is the patch that invalidates the tag.
Comment #19
wim leersLet's inject the
cache_tags.invalidatorservice instead.Comment #20
rodrigoaguileraThank you for the reviews :)
I thought it didn't mattered but I guess I have to learn about the advantages of injecting.
New patch attached
Comment #21
rodrigoaguilerasmall mistake
Comment #26
wim leersWe don't use "I" in comments. Prefer to use "we", or even better, neither.
e.g.
Ensure the 'Translate' local task does not show up anymore when disabling translations for a content type.One comment per statement is excessive. Please group them logically.
Method names must use 3rd singular person, so "Tests", not "Test".
s/rendered/'rendered'/
"new actions in blocks with tabs" does not make sense.
"eg." is not a valid abbreviation.
Comment #27
rodrigoaguileraAdded corrections.
Comment #28
pwolanin commentedlooks possibly related to: #2624594: Local action plugins do not have any way to provide cacheability metadata
Clearing the whole render cache here seems rather like overkill? we don't have a cache tag that generically covers all local tasks?
Comment #29
pwolanin commentedLooks like the local task plugin should have a custom class and expose a cache tag according to what entity and bundle it relates to?
Unfortunately, the local task plugin is associated with a route that applies to the canonical entity view, but the config cache tags are like:
language.content_settings.node.pageso specific to a bundle (e.g. node type). So the local tasks should emit cache tags for all bundles of the entity type, which means they also probably need to include the
entity_bundlescache tag? Or does adding or removing a bundle do a rather blanket wipe on caches?Comment #30
gábor hojtsyComment #31
swentel commentedI think adding or removing a bundle wipes caches. I know it happens for say changing the manage display or form display. Those aren't daily actions, so I think wiping the render cache here is fine since you won't be changing those content language settings often.
Comment #32
tstoecklerRe #29: Do you want a dedicated cache tag because you think clearing the
renderedclears too much that wouldn't actually have to be cleared? If that's the case I disagree because the language configuration is mostly a one-time operation for a site so I don't think we should optimize for that.In general we should never invalidate caches in a form submission, because that means importing config or
drush config-setdoesn't get the same treatment. Instead we should overrideEntityInterface::getCacheTagsToInvalidate()inContentLanguageSettingsto return therenderedcache tag. TheDateFormatconfig entity does this, which similarly is one of those things you set up once and then mostly never touch, so I think that's a pattern we can re-use. Looking atDateFormat::getCacheTagsToInvalidate()I see that it actually just returns['rendered']without delegating to the parent method for the genericconfig:date_format...cache tag. I'm not sure if that is intentional or an oversight (perhaps even a bug?). Looking furtherDateFormatalso haslist_cache_tags = { "rendered" }in its annotation. Not sure whether we need that forContentLanguageSettingsas well. But in general I think that would be a better approach.Comment #33
berdirThat's by design for date formats, we want to avoid adding lots of date format cache tags when we don't need them for invalidation.
Comment #34
tstoecklerAhh thanks, that makes sense. So I guess since for content language settings that's not the case (since they generally will not be part of any output, at least I guess so) it would be best practice to call the parent in
cacheTagsToInvalidate()?Comment #35
berdirI think so, yes.
What's a bit different for them is that we usually save a lot of them on the overview page, possibly dozens. So we'd invalidate the rendered cache tag dozens of times. But we have optimizations in place that will ignore any additional invalidation of the same cache tag in a single request, so that should be OK.
Comment #36
vijaycs85Thanks @tstoeckler and @Berdir. Updated as per #32to #35.
Comment #38
vijaycs85Looks like we just need
list_cache_tags.getCacheTagsToInvalidatehas no effect, becausepostSave()=>invalidateTagsOnSave()=>getEntityType()->getListCacheTags()which just returnsthis->list_cache_tags;Also, the patch is green on both 8.0.x and 8.1.x
Comment #39
tstoecklerAhh, I had looked at
Entity::invalidateTagsOnSave()and had missed the override ofConfigEntityBase::invalidateTagsOnSave(). It does seem a little suspect thatgetCacheTagsToInvalidate()is ignored for config entities, but that's not introduced here, so I think this is good to go. Thanks!Comment #40
swentel commentedRelated issue with config translation, also probably misses a cache tag somewhere.
Comment #41
swentel commentedComment #43
catchCommitted/pushed to all three 8.x branches, thanks!
Comment #45
gábor hojtsyThanks, this was a tough one for users, good to see it fixed!
Comment #47
quietone commented