Problem/Motivation
When adding translations, users expect that they show up immediately. When page caches are involved, that can take quite some time, however.
Proposed resolution
Add a global cache tag for the current language, and invalidate that when saving translations? Could be quite a lot of "tag invalidation noise", when translating a lot of content. is that really worth it?
We decided against this, because it is quite hairy: add a "default" cache tag, that is not a specific cache tag, but that is actually dynamic, because it varies by the contexts… that's not really "default" anymore then, is it?
So while that could definitely be something we want to do eventually, what matters most now is correctness. And therefore, we chose to apply the same approach as the one we used for ThemeSettingsCacheTag
here: invalidate the 'rendered'
cache tag when updating interface translations.
Related, config translation, does that already invalidate the config entity cache tag? should it?
For example, we tag a lot of stuff based on the roles a user has. invalidating all that just because you translated a role label would be a bit stupid, are there cases where it makes sense, e.g. views?
Remaining tasks
None.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#28 | interdiff.txt | 1.22 KB | swentel |
#28 | set_default_cache_tags-2428837-28.patch | 8.22 KB | swentel |
#26 | interdiff.txt | 1.24 KB | swentel |
#26 | set_default_cache_tags-2428837-26.patch | 8.22 KB | swentel |
#24 | interdiff.txt | 3.39 KB | swentel |
Comments
Comment #1
Wim LeersComment #2
Wim LeersI believe this is now blocked on #2428703: Add a 'user.permissions' cache context (was: "Should cache contexts be able to associate a cache tag?").
Comment #3
Wim Leers#2432837: Make cache contexts hierarchical (e.g. 'user' is more specific than 'user.roles') added the
languages:<type>
cache contexts. #2453059: Set default render cache contexts: 'theme' + 'languages:' . LanguageInterface::TYPE_INTERFACE is applying it everywhere. That means that we now know which render arrays should be invalidated by a per-language interface translation cache tag.Once #2428703: Add a 'user.permissions' cache context (was: "Should cache contexts be able to associate a cache tag?") lands, we'll be able to associate such a cache tag with
'languages:' . LanguageInterface::TYPE_INTERFACE
, which would (finally) allow us to solve this issue.Comment #4
Wim Leers#2428703: Add a 'user.permissions' cache context (was: "Should cache contexts be able to associate a cache tag?") landed and settled on a different direction. Therefore this issue needs a slightly new direction too: instead of associating a cache tag with the cache context, we'll need to something analogous to #2453059: Set default render cache contexts: 'theme' + 'languages:' . LanguageInterface::TYPE_INTERFACE: we'll need to set default render cache tags.
Comment #5
Wim LeersComment #6
swentel CreditAttribution: swentel commentedComment #7
swentel CreditAttribution: swentel commentedComment #8
Wim LeersMismatch :) C/p remnant.
Shouldn't we also dispatch this event for the "import translation" UI?
Extraneous newline.
Another remnant.
Comment #9
Wim LeersComment #10
swentel CreditAttribution: swentel commentedAddressed issues, now also has a test - it's a bit longer then removing the 3 lines that we saw :)
Regarding 3: yes, moved that to _locale_refresh_translations().
Comment #12
Wim LeersNit: we always say "render cache", not "rendered cache" :)
These docs are still c/p remnants :P
Nit: This should not be necessary anymore; page cache is already enabled by default.
Also pinged Fabianx for a review.
Comment #13
Fabianx CreditAttribution: Fabianx for Acquia commentedFirst this needs a IS update :) (will review later)
Comment #14
borisson_Changed issues from #12
Comment #15
swentel CreditAttribution: swentel commentedActually, not that I think of it, this is wrong, it doesn't receive any event at all, so this comment can go away completely. Do we want to pass one for consistency and pass on the language that is being invalidated so that anyone else listening to this can enhance this in say contrib ?
Comment #16
catchNow that permission hash is used as the cache context rather than roles, shouldn't we stop doing that? I failed to notice this on the issue that added the permission hash despite that being the whole idea of switching to it...
Comment #17
borisson_Addressed the comment in #15. I have no idea if I should do anything with the comment catch posted. Is there any action I should do now.
Comment #18
Wim LeersMarking as NR for #17.
IS updated.
Let's do this in another issue.
That would indeed be stupid. And we no longer do it. Everything has migrated from "per role" to "per permissions".
Comment #19
Wim LeersComment #20
Wim LeersTwo silly, silly nitpicks:
Missing leading backslash.
80 cols.
Comment #21
swentel CreditAttribution: swentel commentedComment #22
Wim LeersGreat!
Comment #23
alexpottI think we should do the invalidation of the locale tag in this event too. Also I think we should pass the variables $langcodes and $lids so that this event can eventually replace _locale_refresh_translations.
Comment #24
swentel CreditAttribution: swentel commentedComment #25
Wim LeersSorry, a few tiny nitpicks. Once that's done, this is RTBC again.
s/array/string[]/
s/$langcodes/$lang_codes/
Returns the […]
Comment #26
swentel CreditAttribution: swentel commentedComment #27
Wim LeersGah… you changed it the wrong way around :(
We camelCase class properties.
We under_score parameters.
Sorry for the confusion :(
Comment #28
swentel CreditAttribution: swentel commentedComment #29
Wim LeersYay!
Comment #30
alexpottThis issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed f347360 and pushed to 8.0.x. Thanks!
Removed unused use.
Comment #33
maximpodorov CreditAttribution: maximpodorov commentedContinued in #3060007: Adding/updating interface translations should invalidate JavaScript library cache