Problem/Motivation

BlockViewBuilder currently only sets a block plugin's cache contexts if the block is cacheable.

This is wrong: cache contexts must always be set.

Proposed resolution

Fix it.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Comments

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new2.79 KB

Status: Needs review » Needs work

The last submitted patch, 1: block_view_builder_cache_contexts-2458413-1.patch, failed testing.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new3.81 KB
new1.07 KB

And voila, the expected test failure, proving that we indeed have test coverage for this.

wim leers’s picture

Status: Needs review » Needs work
+++ b/core/modules/block/src/BlockViewBuilder.php
@@ -63,21 +69,20 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
+          'contexts' => Cache::mergeContexts($default_cache_contexts, $plugin->getCacheContexts()),

Sigh, I forgot to delete the original line below.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new4.26 KB
new804 bytes

Such a silly mistake.

fabianx’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed fd3a981 and pushed to 8.0.x. Thanks!

  • alexpott committed fd3a981 on 8.0.x
    Issue #2458413 by Wim Leers: BlockViewBuilder should specify cache...

Status: Fixed » Closed (fixed)

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