Loading core/lib/Drupal/Core/Entity/EntityFieldManager.php +23 −9 Original line number Diff line number Diff line Loading @@ -67,6 +67,13 @@ class EntityFieldManager implements EntityFieldManagerInterface, PreWarmableInte */ protected $activeFieldStorageDefinitions; /** * Static cache of base field overrides per entity type and bundle. * * @var array */ protected $baseFieldOverrides; /** * An array of lightweight maps of fields, keyed by entity type. * Loading Loading @@ -392,17 +399,22 @@ protected function buildBundleFieldDefinitions($entity_type_id, $bundle, array $ // overrides of base fields. $bundle_field_definitions = $class::bundleFieldDefinitions($entity_type, $bundle, $base_field_definitions); // Load base field overrides from configuration. These take precedence over // base field overrides returned above. $base_field_override_ids = array_map(function ($field_name) use ($entity_type_id, $bundle) { return $entity_type_id . '.' . $bundle . '.' . $field_name; }, array_keys($base_field_definitions)); $base_field_overrides = $this->entityTypeManager->getStorage('base_field_override')->loadMultiple($base_field_override_ids); foreach ($base_field_overrides as $base_field_override) { if (!isset($this->baseFieldOverrides)) { $this->baseFieldOverrides = []; $base_field_overrides = $this->entityTypeManager->getStorage('base_field_override')->loadMultiple(); foreach ($base_field_overrides as $override) { $this->baseFieldOverrides[$override->getTargetEntityTypeId()][$override->getTargetBundle()][] = $override; } } foreach ($this->baseFieldOverrides[$entity_type_id][$bundle] ?? [] as $base_field_override) { /** @var \Drupal\Core\Field\Entity\BaseFieldOverride $base_field_override */ // Base field definitions can be removed. if (isset($base_field_definitions[$base_field_override->getName()])) { $field_name = $base_field_override->getName(); $bundle_field_definitions[$field_name] = $base_field_override; } } $provider = $entity_type->getProvider(); foreach ($bundle_field_definitions as $definition) { Loading Loading @@ -628,6 +640,7 @@ public function clearCachedFieldDefinitions() { $this->fieldMapByFieldType = []; $this->entityDisplayRepository->clearDisplayModeInfo(); $this->extraFields = NULL; $this->baseFieldOverrides = NULL; Cache::invalidateTags(['entity_field_info']); // The typed data manager statically caches prototype objects with injected // definitions, clear those as well. Loading @@ -644,6 +657,7 @@ public function useCaches($use_caches = FALSE) { $this->baseFieldDefinitions = []; $this->fieldStorageDefinitions = []; $this->activeFieldStorageDefinitions = []; $this->baseFieldOverrides = NULL; } } Loading core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryAuthenticatedPerformanceTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -128,10 +128,10 @@ protected function doTestNodePageAdministrator(): void { }, 'administratorNodePage'); $expected = [ 'QueryCount' => 435, 'CacheGetCount' => 484, 'QueryCount' => 418, 'CacheGetCount' => 466, 'CacheGetCountByBin' => [ 'config' => 174, 'config' => 156, 'bootstrap' => 16, 'discovery' => 107, 'data' => 67, Loading @@ -141,7 +141,7 @@ protected function doTestNodePageAdministrator(): void { 'render' => 39, 'menu' => 24, ], 'CacheSetCount' => 467, 'CacheSetCount' => 449, 'CacheDeleteCount' => 0, 'CacheTagInvalidationCount' => 0, 'CacheTagLookupQueryCount' => 51, Loading core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php +3 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,9 @@ protected function testFrontPageColdCache(): void { $this->assertSession()->pageTextContains('Umami'); $expected = [ 'QueryCount' => 350, 'CacheGetCount' => 451, 'CacheSetCount' => 445, 'QueryCount' => 336, 'CacheGetCount' => 436, 'CacheSetCount' => 430, 'CacheDeleteCount' => 0, 'CacheTagLookupQueryCount' => 49, 'CacheTagInvalidationCount' => 0, Loading core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -55,8 +55,8 @@ protected function testNodePageColdCache(): void { $this->assertSession()->pageTextContains('quiche'); $expected = [ 'QueryCount' => 361, 'CacheSetCount' => 422, 'QueryCount' => 345, 'CacheSetCount' => 405, 'CacheDeleteCount' => 0, 'CacheTagLookupQueryCount' => 45, 'CacheTagInvalidationCount' => 0, Loading Loading @@ -117,9 +117,9 @@ protected function testNodePageCoolCache(): void { $this->assertSession()->pageTextContains('quiche'); $expected = [ 'QueryCount' => 111, 'QueryCount' => 110, 'CacheGetCount' => 214, 'CacheSetCount' => 66, 'CacheSetCount' => 64, 'CacheDeleteCount' => 0, 'CacheTagInvalidationCount' => 0, 'CacheTagLookupQueryCount' => 25, Loading core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -619,7 +619,7 @@ protected function setUpEntityWithFieldDefinition($custom_invoke_all = FALSE, $f $this->setUpEntityTypeDefinitions(['test_entity_type' => $this->entityType, 'base_field_override' => $override_entity_type]); $storage = $this->prophesize(EntityStorageInterface::class); $storage->loadMultiple(Argument::type('array'))->willReturn([]); $storage->loadMultiple()->willReturn([]); // By default, make the storage entity class lookup return the // EntityTypeManagerTestEntity class. Loading Loading
core/lib/Drupal/Core/Entity/EntityFieldManager.php +23 −9 Original line number Diff line number Diff line Loading @@ -67,6 +67,13 @@ class EntityFieldManager implements EntityFieldManagerInterface, PreWarmableInte */ protected $activeFieldStorageDefinitions; /** * Static cache of base field overrides per entity type and bundle. * * @var array */ protected $baseFieldOverrides; /** * An array of lightweight maps of fields, keyed by entity type. * Loading Loading @@ -392,17 +399,22 @@ protected function buildBundleFieldDefinitions($entity_type_id, $bundle, array $ // overrides of base fields. $bundle_field_definitions = $class::bundleFieldDefinitions($entity_type, $bundle, $base_field_definitions); // Load base field overrides from configuration. These take precedence over // base field overrides returned above. $base_field_override_ids = array_map(function ($field_name) use ($entity_type_id, $bundle) { return $entity_type_id . '.' . $bundle . '.' . $field_name; }, array_keys($base_field_definitions)); $base_field_overrides = $this->entityTypeManager->getStorage('base_field_override')->loadMultiple($base_field_override_ids); foreach ($base_field_overrides as $base_field_override) { if (!isset($this->baseFieldOverrides)) { $this->baseFieldOverrides = []; $base_field_overrides = $this->entityTypeManager->getStorage('base_field_override')->loadMultiple(); foreach ($base_field_overrides as $override) { $this->baseFieldOverrides[$override->getTargetEntityTypeId()][$override->getTargetBundle()][] = $override; } } foreach ($this->baseFieldOverrides[$entity_type_id][$bundle] ?? [] as $base_field_override) { /** @var \Drupal\Core\Field\Entity\BaseFieldOverride $base_field_override */ // Base field definitions can be removed. if (isset($base_field_definitions[$base_field_override->getName()])) { $field_name = $base_field_override->getName(); $bundle_field_definitions[$field_name] = $base_field_override; } } $provider = $entity_type->getProvider(); foreach ($bundle_field_definitions as $definition) { Loading Loading @@ -628,6 +640,7 @@ public function clearCachedFieldDefinitions() { $this->fieldMapByFieldType = []; $this->entityDisplayRepository->clearDisplayModeInfo(); $this->extraFields = NULL; $this->baseFieldOverrides = NULL; Cache::invalidateTags(['entity_field_info']); // The typed data manager statically caches prototype objects with injected // definitions, clear those as well. Loading @@ -644,6 +657,7 @@ public function useCaches($use_caches = FALSE) { $this->baseFieldDefinitions = []; $this->fieldStorageDefinitions = []; $this->activeFieldStorageDefinitions = []; $this->baseFieldOverrides = NULL; } } Loading
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryAuthenticatedPerformanceTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -128,10 +128,10 @@ protected function doTestNodePageAdministrator(): void { }, 'administratorNodePage'); $expected = [ 'QueryCount' => 435, 'CacheGetCount' => 484, 'QueryCount' => 418, 'CacheGetCount' => 466, 'CacheGetCountByBin' => [ 'config' => 174, 'config' => 156, 'bootstrap' => 16, 'discovery' => 107, 'data' => 67, Loading @@ -141,7 +141,7 @@ protected function doTestNodePageAdministrator(): void { 'render' => 39, 'menu' => 24, ], 'CacheSetCount' => 467, 'CacheSetCount' => 449, 'CacheDeleteCount' => 0, 'CacheTagInvalidationCount' => 0, 'CacheTagLookupQueryCount' => 51, Loading
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php +3 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,9 @@ protected function testFrontPageColdCache(): void { $this->assertSession()->pageTextContains('Umami'); $expected = [ 'QueryCount' => 350, 'CacheGetCount' => 451, 'CacheSetCount' => 445, 'QueryCount' => 336, 'CacheGetCount' => 436, 'CacheSetCount' => 430, 'CacheDeleteCount' => 0, 'CacheTagLookupQueryCount' => 49, 'CacheTagInvalidationCount' => 0, Loading
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -55,8 +55,8 @@ protected function testNodePageColdCache(): void { $this->assertSession()->pageTextContains('quiche'); $expected = [ 'QueryCount' => 361, 'CacheSetCount' => 422, 'QueryCount' => 345, 'CacheSetCount' => 405, 'CacheDeleteCount' => 0, 'CacheTagLookupQueryCount' => 45, 'CacheTagInvalidationCount' => 0, Loading Loading @@ -117,9 +117,9 @@ protected function testNodePageCoolCache(): void { $this->assertSession()->pageTextContains('quiche'); $expected = [ 'QueryCount' => 111, 'QueryCount' => 110, 'CacheGetCount' => 214, 'CacheSetCount' => 66, 'CacheSetCount' => 64, 'CacheDeleteCount' => 0, 'CacheTagInvalidationCount' => 0, 'CacheTagLookupQueryCount' => 25, Loading
core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -619,7 +619,7 @@ protected function setUpEntityWithFieldDefinition($custom_invoke_all = FALSE, $f $this->setUpEntityTypeDefinitions(['test_entity_type' => $this->entityType, 'base_field_override' => $override_entity_type]); $storage = $this->prophesize(EntityStorageInterface::class); $storage->loadMultiple(Argument::type('array'))->willReturn([]); $storage->loadMultiple()->willReturn([]); // By default, make the storage entity class lookup return the // EntityTypeManagerTestEntity class. Loading