Skip to content
Snippets Groups Projects
Verified Commit 0f891c58 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3056135 by tim.plunkett, tedbow, Wim Leers, marcoscano, rpayanm,...

Issue #3056135 by tim.plunkett, tedbow, Wim Leers, marcoscano, rpayanm, raman.b, smustgrave: Viewing Layout Builder enable node fails after Workflow enabled on bundle if another node was created before enabling
parent b70dfff4
No related branches found
No related tags found
No related merge requests found
...@@ -43,11 +43,8 @@ protected function setUp(): void { ...@@ -43,11 +43,8 @@ protected function setUp(): void {
// https://www.drupal.org/project/drupal/issues/2917777. // https://www.drupal.org/project/drupal/issues/2917777.
$this->drupalPlaceBlock('local_tasks_block'); $this->drupalPlaceBlock('local_tasks_block');
$workflow = $this->createEditorialWorkflow(); // Add a new bundle.
// Add a new bundle and add an editorial workflow.
$this->createContentType(['type' => 'bundle_with_section_field']); $this->createContentType(['type' => 'bundle_with_section_field']);
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'bundle_with_section_field');
// Add a new block content bundle to the editorial workflow. // Add a new block content bundle to the editorial workflow.
BlockContentType::create([ BlockContentType::create([
...@@ -57,14 +54,29 @@ protected function setUp(): void { ...@@ -57,14 +54,29 @@ protected function setUp(): void {
])->save(); ])->save();
block_content_add_body_field('basic'); block_content_add_body_field('basic');
$workflow->getTypePlugin()->addEntityTypeAndBundle('block_content', 'basic');
$workflow->save();
// Enable layout overrides. // Enable layout overrides.
LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default') LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
->enableLayoutBuilder() ->enableLayoutBuilder()
->setOverridable() ->setOverridable()
->save(); ->save();
// Create a node before enabling the workflow on the bundle.
$node = $this->createNode([
'type' => 'bundle_with_section_field',
'title' => 'Pre-workflow node',
'body' => [
[
'value' => 'The first node body',
],
],
]);
// View the node to ensure the new extra field blocks are not cached when
// the workflow is updated.
$this->drupalGet($node->toUrl());
// Add editorial workflow for the bundle.
$workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('block_content', 'basic');
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'bundle_with_section_field');
$workflow->save();
$this->drupalLogin($this->drupalCreateUser([ $this->drupalLogin($this->drupalCreateUser([
'configure any layout', 'configure any layout',
......
...@@ -37,6 +37,12 @@ services: ...@@ -37,6 +37,12 @@ services:
arguments: ['@current_route_match'] arguments: ['@current_route_match']
tags: tags:
- { name: cache.context } - { name: cache.context }
layout_builder.extra_fields.invalidator:
class: Drupal\layout_builder\Cache\ExtraFieldBlockCacheTagInvalidator
arguments: ['@plugin.manager.block']
public: false
tags:
- { name: cache_tags_invalidator }
layout_builder.sample_entity_generator: layout_builder.sample_entity_generator:
class: Drupal\layout_builder\Entity\LayoutBuilderSampleEntityGenerator class: Drupal\layout_builder\Entity\LayoutBuilderSampleEntityGenerator
arguments: ['@tempstore.shared', '@entity_type.manager'] arguments: ['@tempstore.shared', '@entity_type.manager']
......
<?php
namespace Drupal\layout_builder\Cache;
use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
use Drupal\Core\Block\BlockManagerInterface;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
/**
* Provides a cache tag invalidator that clears the block cache.
*
* @internal
* Tagged services are internal.
*/
class ExtraFieldBlockCacheTagInvalidator implements CacheTagsInvalidatorInterface {
/**
* Constructs a new ExtraFieldBlockCacheTagInvalidator.
*
* @param \Drupal\Core\Block\BlockManagerInterface $blockManager
* The block manager.
*/
public function __construct(protected BlockManagerInterface $blockManager) {
}
/**
* {@inheritdoc}
*/
public function invalidateTags(array $tags) {
if (in_array('entity_field_info', $tags, TRUE)) {
if ($this->blockManager instanceof CachedDiscoveryInterface) {
$this->blockManager->clearCachedDefinitions();
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment