Loading core/lib/Drupal/Core/Form/ConfigFormBase.php +17 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ namespace Drupal\Core\Form; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\Config; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\TypedConfigManagerInterface; Loading Loading @@ -147,7 +149,21 @@ public function storeConfigKeyToFormElementMap(array $element, FormStateInterfac // rebuilding the form. $form_state->set(static::CONFIG_KEY_TO_FORM_ELEMENT_MAP, []); return $this->doStoreConfigMap($element, $form_state); $element = $this->doStoreConfigMap($element, $form_state); // Use the map to set the cacheability metadata on the form. $map = $form_state->get(static::CONFIG_KEY_TO_FORM_ELEMENT_MAP) ?? []; $tags = []; foreach (array_merge(array_keys($map), $this->getEditableConfigNames()) as $config_name) { $tags = Cache::mergeTags( $tags, $this->configFactory()->getEditable($config_name)->getCacheTags() ); } if (!empty($tags)) { CacheableMetadata::createFromRenderArray($element)->addCacheTags($tags)->applyTo($element); } return $element; } /** Loading core/modules/filter/src/Element/TextFormat.php +3 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,9 @@ public static function processFormat(&$element, FormStateInterface $form_state, '#process', // Ensure #pre_render functions will be run. '#pre_render', // Do not copy #config_target to prevent multiple elements targeting the // same property. '#config_target', // Description is handled by theme_text_format_wrapper(). '#description', // Ensure proper ordering of children. Loading core/modules/navigation/tests/src/Functional/NavigationShortcutsBlockTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public function testNavigationBlock(): void { 'block_view', 'config:block.block.title', 'config:block_list', 'config:system.cron', 'config:navigation.settings', 'config:navigation.block_layout', 'config:shortcut.set.default', Loading core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ public function testToolbar(): void { 'block_view', 'config:block.block.title', 'config:block_list', 'config:system.cron', 'config:shortcut.set.default', 'config:system.menu.admin', 'config:system.theme', Loading Loading @@ -278,6 +279,7 @@ public function testBlock(): void { 'config:block.block.shortcuts', 'config:block.block.title', 'config:block_list', 'config:system.cron', 'config:shortcut.set.default', 'config:system.menu.admin', 'config:system.theme', Loading core/modules/system/tests/modules/form_test/config/schema/form_test.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -25,3 +25,6 @@ form_test.object: choices: - fruits - vegetables motivation: type: text_format label: 'Motivation' Loading
core/lib/Drupal/Core/Form/ConfigFormBase.php +17 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ namespace Drupal\Core\Form; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\Config; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\TypedConfigManagerInterface; Loading Loading @@ -147,7 +149,21 @@ public function storeConfigKeyToFormElementMap(array $element, FormStateInterfac // rebuilding the form. $form_state->set(static::CONFIG_KEY_TO_FORM_ELEMENT_MAP, []); return $this->doStoreConfigMap($element, $form_state); $element = $this->doStoreConfigMap($element, $form_state); // Use the map to set the cacheability metadata on the form. $map = $form_state->get(static::CONFIG_KEY_TO_FORM_ELEMENT_MAP) ?? []; $tags = []; foreach (array_merge(array_keys($map), $this->getEditableConfigNames()) as $config_name) { $tags = Cache::mergeTags( $tags, $this->configFactory()->getEditable($config_name)->getCacheTags() ); } if (!empty($tags)) { CacheableMetadata::createFromRenderArray($element)->addCacheTags($tags)->applyTo($element); } return $element; } /** Loading
core/modules/filter/src/Element/TextFormat.php +3 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,9 @@ public static function processFormat(&$element, FormStateInterface $form_state, '#process', // Ensure #pre_render functions will be run. '#pre_render', // Do not copy #config_target to prevent multiple elements targeting the // same property. '#config_target', // Description is handled by theme_text_format_wrapper(). '#description', // Ensure proper ordering of children. Loading
core/modules/navigation/tests/src/Functional/NavigationShortcutsBlockTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public function testNavigationBlock(): void { 'block_view', 'config:block.block.title', 'config:block_list', 'config:system.cron', 'config:navigation.settings', 'config:navigation.block_layout', 'config:shortcut.set.default', Loading
core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ public function testToolbar(): void { 'block_view', 'config:block.block.title', 'config:block_list', 'config:system.cron', 'config:shortcut.set.default', 'config:system.menu.admin', 'config:system.theme', Loading Loading @@ -278,6 +279,7 @@ public function testBlock(): void { 'config:block.block.shortcuts', 'config:block.block.title', 'config:block_list', 'config:system.cron', 'config:shortcut.set.default', 'config:system.menu.admin', 'config:system.theme', Loading
core/modules/system/tests/modules/form_test/config/schema/form_test.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -25,3 +25,6 @@ form_test.object: choices: - fruits - vegetables motivation: type: text_format label: 'Motivation'