Problem/Motivation
[#2451661] introduced languages:<language type>
cache contexts. This allows e.g. something that uses only the t()
function to indicate that it varies by the negotiated interface language cache context, and an entity rendered in the negotiated language to indicate that it varies by the negotiated content language cache context.
Views' \Drupal\views\Entity\Render\RendererBase
, however, sets the all-encompassing languages
cache context, whereas it really should set only 'languages:' . LanguageInterface::TYPE_CONTENT
.
This problem was also encountered in #1867518: Leverage entityDisplay to provide fast rendering for fields (see comments 89 & 93). This issue moves those changes out of that issue.
Proposed resolution
But really, this is a base class, and only one of the three classes using it actually only vary by this cache context:
TranslationLanguageRenderer
should return['languages:' . LanguageInterface::TYPE_CONTENT]
, since it uses the negotiated languageDefaultLanguageRenderer
should return[]
, since it uses the untranslated/original language of the entityConfigurableLanguageRenderer
should return[]
, since it uses a configurable (in the view), non-negotiated language of the entity
Remaining tasks
None.
User interface changes
None.
API changes
None.
Beta phase evaluation
Issue category | Bug because the cache context is not precise as it can be. |
---|---|
Prioritized changes | The main goal of this issue is performance (as precise cache contexts as possible) and DX (setting the right example in core). |
Disruption | Zero disruption. |
Comment | File | Size | Author |
---|---|---|---|
#10 | 2462851-10.patch | 3.02 KB | rpayanm |
#10 | 2462851-interdiff.txt | 1014 bytes | rpayanm |
Comments
Comment #1
Wim LeersComment #2
Wim LeersComment #3
Fabianx CreditAttribution: Fabianx commentedRTBC, this makes a lot of sense and simplifies the logic.
Comment #4
dawehner+1
Comment #6
Fabianx CreditAttribution: Fabianx commentedComment #7
rpayanmComment #8
Fabianx CreditAttribution: Fabianx for Drupal Association commentedBack to RTBC - if tests still pass ...
Comment #10
rpayanmComment #11
rpayanmPer #8
Comment #12
Fabianx CreditAttribution: Fabianx for Drupal Association commentedRTBC + 1
Comment #13
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes.Committed 4112ca1 and pushed to 8.0.x. Thanks!