diff --git a/core/core.services.yml b/core/core.services.yml index 1fed8e1a841877d720e04a351fae2b258b27faca..9f5d6fc325bb92791a1d5a20499cb144575a91b0 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -508,6 +508,8 @@ services: validation.constraint: class: Drupal\Core\Validation\ConstraintManager parent: default_plugin_manager + tags: + - { name: plugin_manager_cache_clear } lock: class: Drupal\Core\Lock\DatabaseLockBackend arguments: ['@database'] diff --git a/core/modules/system/src/Tests/Entity/EntityValidationTest.php b/core/modules/system/src/Tests/Entity/EntityValidationTest.php index 719b78336f89111424a6e747a15f561af44b6b10..44c90316365ee969d3765a1123b09a265acfa53d 100644 --- a/core/modules/system/src/Tests/Entity/EntityValidationTest.php +++ b/core/modules/system/src/Tests/Entity/EntityValidationTest.php @@ -79,6 +79,19 @@ protected function createTestEntity($entity_type) { * Tests validating test entity types. */ public function testValidation() { + // Ensure that the constraint manager is marked as cached cleared. + $plugin_cache_clearer = \Drupal::service('plugin.cache_clearer'); + $get_cached_discoveries = function () { + return $this->cachedDiscoveries; + }; + $get_cached_discoveries = $get_cached_discoveries->bindTo($plugin_cache_clearer, $plugin_cache_clearer); + $cached_discoveries = $get_cached_discoveries(); + $cached_discovery_classes = []; + foreach ($cached_discoveries as $cached_discovery) { + $cached_discovery_classes[] = get_class($cached_discovery); + } + $this->assertTrue(in_array('Drupal\Core\Validation\ConstraintManager', $cached_discovery_classes)); + // All entity variations have to have the same results. foreach (entity_test_entity_types() as $entity_type) { $this->checkValidation($entity_type);