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:

  1. TranslationLanguageRenderer should return ['languages:' . LanguageInterface::TYPE_CONTENT], since it uses the negotiated language
  2. DefaultLanguageRenderer should return [], since it uses the untranslated/original language of the entity
  3. ConfigurableLanguageRenderer 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

Reference: https://www.drupal.org/core/beta-changes
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.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Title: Improve Views entity renderer plugins' cache contexts » Improve Views entity row renderer plugins' cache contexts
Status: Active » Needs review
FileSize
3.33 KB
Wim Leers’s picture

Category: Task » Bug report
Issue summary: View changes
Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBC, this makes a lot of sense and simplifies the logic.

dawehner’s picture

+1

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1: views_entity_row_renderer_cache_contexts-2462851-1.patch, failed testing.

Fabianx’s picture

Issue tags: +Needs reroll
rpayanm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3 KB
Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC - if tests still pass ...

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2462851-7.patch, failed testing.

rpayanm’s picture

Status: Needs work » Needs review
FileSize
1014 bytes
3.02 KB
rpayanm’s picture

Status: Needs review » Reviewed & tested by the community

Per #8

Fabianx’s picture

RTBC + 1

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This 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!

  • alexpott committed 4112ca1 on 8.0.x
    Issue #2462851 by rpayanm, Wim Leers: Improve Views entity row renderer...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.