diff --git a/core/lib/Drupal/Core/Entity/EntityBundleListener.php b/core/lib/Drupal/Core/Entity/EntityBundleListener.php index e3b219b39c..e37317a020 100644 --- a/core/lib/Drupal/Core/Entity/EntityBundleListener.php +++ b/core/lib/Drupal/Core/Entity/EntityBundleListener.php @@ -68,6 +68,7 @@ public function onBundleCreate($bundle, $entity_type_id) { } // Invoke hook_entity_bundle_create() hook. $this->moduleHandler->invokeAll('entity_bundle_create', [$entity_type_id, $bundle]); + $this->entityFieldManager->clearCachedFieldDefinitions(); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityFieldManager.php b/core/lib/Drupal/Core/Entity/EntityFieldManager.php index f847cfa384..88186c6706 100644 --- a/core/lib/Drupal/Core/Entity/EntityFieldManager.php +++ b/core/lib/Drupal/Core/Entity/EntityFieldManager.php @@ -497,7 +497,7 @@ public function getFieldMap() { } } - $this->cacheSet($cid, $this->fieldMap, Cache::PERMANENT, ['entity_types']); + $this->cacheSet($cid, $this->fieldMap, Cache::PERMANENT, ['entity_types', 'entity_field_info']); } } return $this->fieldMap; diff --git a/core/modules/layout_builder/layout_builder.module b/core/modules/layout_builder/layout_builder.module index 76ec53433d..361a7ae73f 100644 --- a/core/modules/layout_builder/layout_builder.module +++ b/core/modules/layout_builder/layout_builder.module @@ -66,6 +66,14 @@ function layout_builder_form_entity_form_display_edit_form_alter(&$form, FormSta } } +/** + * Implements hook_entity_bundle_create(). + */ +function layout_builder_entity_bundle_create($entity_type_id, $bundle) { + // Clear the list of blocks when a new bundle is created. + \Drupal::service('plugin.manager.block')->clearCachedDefinitions(); +} + /** * Implements hook_field_config_insert(). */ diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutTaxonomyTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutTaxonomyTest.php index 5fc3ee6c57..d7e19df84d 100644 --- a/core/modules/layout_builder/tests/src/Functional/LayoutTaxonomyTest.php +++ b/core/modules/layout_builder/tests/src/Functional/LayoutTaxonomyTest.php @@ -21,29 +21,15 @@ class LayoutTaxonomyTest extends BrowserTestBase { protected static $modules = [ 'views', 'layout_builder', - 'layout_builder_views_test', - 'layout_test', - 'block', 'taxonomy', - 'layout_builder_test', ]; - /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - - // @todo The Layout Builder UI relies on local tasks; fix in - // https://www.drupal.org/project/drupal/issues/2917777. - $this->drupalPlaceBlock('local_tasks_block'); - } - /** * Tests layout builder interaction with taxonomy. */ public function testTaxonomyLayoutBuilderInteraction() { - // Create two nodes. + $assert_session = $this->assertSession(); + $vocabulary = $this->createVocabulary(); EntityViewDisplay::create([ 'targetEntityType' => 'taxonomy_term', @@ -56,8 +42,9 @@ public function testTaxonomyLayoutBuilderInteraction() { $term = $this->createTerm($vocabulary); $this->drupalGet($term->toUrl()); - $this->assertSession()->statusCodeEquals(200); + $assert_session->statusCodeEquals(200); $this->assertNotEmpty($this->cssSelect('.layout--onecol')); + $assert_session->pageTextContains($term->getDescription()); } }