From 53fad5c5a262ff389d28c70299c38d13c55047c6 Mon Sep 17 00:00:00 2001 From: catch <6915-catch@users.noreply.drupalcode.org> Date: Mon, 10 Feb 2025 17:38:56 +0000 Subject: [PATCH] Issue #3505059 by kristiaanvandeneynde, berdir, catch: Remove entity_type_values cache tags --- .../CacheTagPreloadSubscriber.php | 1 - .../Core/Entity/ContentEntityStorageBase.php | 9 ++------- .../StandardPerformanceTest.php | 16 +++++++--------- .../Entity/Sql/SqlContentEntityStorageTest.php | 2 +- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/EventSubscriber/CacheTagPreloadSubscriber.php b/core/lib/Drupal/Core/Cache/EventSubscriber/CacheTagPreloadSubscriber.php index af3dedfab565..c63a37214483 100644 --- a/core/lib/Drupal/Core/Cache/EventSubscriber/CacheTagPreloadSubscriber.php +++ b/core/lib/Drupal/Core/Cache/EventSubscriber/CacheTagPreloadSubscriber.php @@ -35,7 +35,6 @@ public function onRequest(RequestEvent $event): void { 'entity_bundles', 'local_task', 'library_info', - 'user_values', ], Settings::get('cache_preload_tags', [])); $this->cacheTagsChecksum->registerCacheTagsForPreload($default_preload_cache_tags); } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index 627aabf20fe6..d082919f11ba 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -2,7 +2,6 @@ namespace Drupal\Core\Entity; -use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; use Drupal\Core\Entity\Exception\AmbiguousBundleClassException; @@ -1123,15 +1122,11 @@ protected function setPersistentCache($entities) { return; } - $cache_tags = [ - $this->entityTypeId . '_values', - 'entity_field_info', - ]; $items = []; foreach ($entities as $id => $entity) { $items[$this->buildCacheId($id)] = [ 'data' => $entity, - 'tags' => $cache_tags, + 'tags' => ['entity_field_info'], ]; } $this->cacheBackend->setMultiple($items); @@ -1210,7 +1205,7 @@ public function resetCache(?array $ids = NULL) { else { parent::resetCache(); if ($this->entityType->isPersistentlyCacheable()) { - Cache::invalidateTags([$this->entityTypeId . '_values']); + $this->cacheBackend->deleteAll(); } $this->latestRevisionIds = []; } diff --git a/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php b/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php index b754ec94f444..d212ed46ae92 100644 --- a/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php +++ b/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php @@ -145,12 +145,11 @@ protected function testAnonymous(): void { 'CacheTagChecksumCount' => 37, 'CacheTagIsValidCount' => 42, 'CacheTagInvalidationCount' => 0, - 'CacheTagLookupQueryCount' => 22, + 'CacheTagLookupQueryCount' => 21, 'CacheTagGroupedLookups' => [ - ['route_match', 'access_policies', 'routes', 'router', 'entity_types', 'entity_field_info', 'entity_bundles', 'local_task', 'library_info', 'user_values'], + ['route_match', 'access_policies', 'routes', 'router', 'entity_types', 'entity_field_info', 'entity_bundles', 'local_task', 'library_info'], ['config:views.view.frontpage'], ['config:core.extension', 'views_data'], - ['node_values'], ['node:1', 'node_list'], ['rendered', 'user:0', 'user_view'], ['config:filter.format.restricted_html', 'node_view'], @@ -211,10 +210,9 @@ protected function testAnonymous(): void { 'CacheSetCount' => 16, 'CacheDeleteCount' => 0, 'CacheTagInvalidationCount' => 0, - 'CacheTagLookupQueryCount' => 19, + 'CacheTagLookupQueryCount' => 18, 'CacheTagGroupedLookups' => [ - ['route_match', 'access_policies', 'routes', 'router', 'entity_types', 'entity_field_info', 'entity_bundles', 'local_task', 'library_info', 'user_values'], - ['node_values'], + ['route_match', 'access_policies', 'routes', 'router', 'entity_types', 'entity_field_info', 'entity_bundles', 'local_task', 'library_info'], ['rendered', 'user:0', 'user_view'], ['config:filter.format.restricted_html', 'node:1', 'node_view'], ['block_view', 'config:block.block.stark_site_branding', 'config:system.site'], @@ -331,9 +329,9 @@ protected function testLogin(): void { 'CacheTagLookupQueryCount' => 17, 'CacheTagGroupedLookups' => [ // Form submission and login. - ['route_match', 'access_policies', 'routes', 'router', 'entity_types', 'entity_field_info', 'entity_bundles', 'local_task', 'library_info', 'user_values'], + ['route_match', 'access_policies', 'routes', 'router', 'entity_types', 'entity_field_info', 'entity_bundles', 'local_task', 'library_info'], // The user page after the redirect. - ['route_match', 'access_policies', 'routes', 'router', 'entity_types', 'entity_field_info', 'entity_bundles', 'local_task', 'library_info', 'user_values'], + ['route_match', 'access_policies', 'routes', 'router', 'entity_types', 'entity_field_info', 'entity_bundles', 'local_task', 'library_info'], ['rendered', 'user:2', 'user_view'], ['block_view', 'config:block.block.stark_site_branding', 'config:system.site'], ['CACHE_MISS_IF_UNCACHEABLE_HTTP_METHOD:form', 'config:block.block.stark_search_form_narrow', 'config:search.settings'], @@ -407,7 +405,7 @@ protected function testLoginBlock(): void { 'CacheTagChecksumCount' => 1, 'CacheTagIsValidCount' => 41, 'CacheTagInvalidationCount' => 0, - 'CacheTagLookupQueryCount' => 20, + 'CacheTagLookupQueryCount' => 19, ]; $this->assertMetrics($expected, $performance_data); } diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php index ac82ac94c5ff..37cede409b88 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php @@ -1308,7 +1308,7 @@ public function testLoadMultiplePersistentCacheMiss(): void { ->with([ $key => [ 'data' => $entity, - 'tags' => [$this->entityTypeId . '_values', 'entity_field_info'], + 'tags' => ['entity_field_info'], ], ]); -- GitLab