Loading core/lib/Drupal/Core/Entity/EntityFieldManager.php +6 −21 Original line number Diff line number Diff line Loading @@ -539,30 +539,15 @@ public function getFieldMap() { 'bundles' => array_combine($bundles, $bundles), ]; } foreach ($bundles as $bundle) { $fields = $this->getFieldDefinitions($entity_type_id, $bundle); foreach ($fields as $field_name => $field_definition) { $this->fieldMap[$entity_type_id][$field_name]['type'] = $field_definition->getType(); $this->fieldMap[$entity_type_id][$field_name]['bundles'][$bundle] = $bundle; } } // In the second step, the per-bundle fields are added, based on the // persistent bundle field map stored in a key value collection. This // data is managed in the // FieldDefinitionListener::onFieldDefinitionCreate() and // FieldDefinitionListener::onFieldDefinitionDelete() methods. // Rebuilding this information in the same way as base fields would not // scale, as the time to query would grow exponentially with more fields // and bundles. A cache would be deleted during cache clears, which is // the only time it is needed, so a key value collection is used. $bundle_field_maps = $this->keyValueFactory->get('entity.definitions.bundle_field_map')->getAll(); foreach ($bundle_field_maps as $entity_type_id => $bundle_field_map) { foreach ($bundle_field_map as $field_name => $map_entry) { if (!isset($this->fieldMap[$entity_type_id][$field_name])) { $this->fieldMap[$entity_type_id][$field_name] = $map_entry; } else { $this->fieldMap[$entity_type_id][$field_name]['bundles'] += $map_entry['bundles']; } } } $this->cacheSet($cid, $this->fieldMap, Cache::PERMANENT, ['entity_types', 'entity_field_info']); } } Loading core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ public function testSettingsUI(): void { ]; $this->assertSettings('comment', 'comment_article', TRUE, $edit); $entity_field_manager = \Drupal::service('entity_field.manager'); $entity_field_manager->clearCachedFieldDefinitions(); $definition = $entity_field_manager->getFieldDefinitions('comment', 'comment_article')['comment_body']; $this->assertTrue($definition->isTranslatable(), 'Article comment body is translatable.'); $definition = $entity_field_manager->getFieldDefinitions('comment', 'comment_article')['subject']; Loading core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ public function entityBundleInfo(): array { $bundles = []; $entity_types = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_types as $entity_type_id => $entity_type) { if ($entity_type->getProvider() == 'entity_test' if (in_array($entity_type->getProvider(), ['entity_test', 'entity_test_update'], TRUE) && !in_array($entity_type_id, ['entity_test_with_bundle', 'entity_test_mul_with_bundle'], TRUE)) { $bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles', [$entity_type_id => ['label' => 'Entity Test Bundle']]); } Loading core/modules/views/tests/src/Kernel/FieldApiDataTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,7 @@ public function testViewsData(): void { // selected by EntityFieldManagerInterface::getFieldLabels(). $this->assertEquals('GiraffeB" label (field_string)', $data[$current_table][$field_storage_string->getName() . '_value']['title']); $this->assertInstanceOf(MarkupInterface::class, $data[$current_table][$field_storage_string->getName()]['help']); $this->assertEquals('Appears in: page, article, news. Also known as: Content: GiraffeA" label', $data[$current_table][$field_storage_string->getName()]['help']); $this->assertEquals('Appears in: article, page, news. Also known as: Content: GiraffeA" label', $data[$current_table][$field_storage_string->getName()]['help']); } /** Loading core/modules/views_ui/tests/src/Functional/HandlerTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -220,7 +220,7 @@ public function testHandlerHelpEscaping(): void { $this->drupalGet('admin/structure/views/nojs/add-handler/content/default/field'); $this->assertSession()->assertEscaped('The <em>giraffe"</em> label <script>alert("the return of the xss")</script>'); $this->assertSession()->assertEscaped('Appears in: page, article. Also known as: Content: The giraffe" label'); $this->assertSession()->assertEscaped('Appears in: article, page. Also known as: Content: The giraffe" label'); } /** Loading Loading
core/lib/Drupal/Core/Entity/EntityFieldManager.php +6 −21 Original line number Diff line number Diff line Loading @@ -539,30 +539,15 @@ public function getFieldMap() { 'bundles' => array_combine($bundles, $bundles), ]; } foreach ($bundles as $bundle) { $fields = $this->getFieldDefinitions($entity_type_id, $bundle); foreach ($fields as $field_name => $field_definition) { $this->fieldMap[$entity_type_id][$field_name]['type'] = $field_definition->getType(); $this->fieldMap[$entity_type_id][$field_name]['bundles'][$bundle] = $bundle; } } // In the second step, the per-bundle fields are added, based on the // persistent bundle field map stored in a key value collection. This // data is managed in the // FieldDefinitionListener::onFieldDefinitionCreate() and // FieldDefinitionListener::onFieldDefinitionDelete() methods. // Rebuilding this information in the same way as base fields would not // scale, as the time to query would grow exponentially with more fields // and bundles. A cache would be deleted during cache clears, which is // the only time it is needed, so a key value collection is used. $bundle_field_maps = $this->keyValueFactory->get('entity.definitions.bundle_field_map')->getAll(); foreach ($bundle_field_maps as $entity_type_id => $bundle_field_map) { foreach ($bundle_field_map as $field_name => $map_entry) { if (!isset($this->fieldMap[$entity_type_id][$field_name])) { $this->fieldMap[$entity_type_id][$field_name] = $map_entry; } else { $this->fieldMap[$entity_type_id][$field_name]['bundles'] += $map_entry['bundles']; } } } $this->cacheSet($cid, $this->fieldMap, Cache::PERMANENT, ['entity_types', 'entity_field_info']); } } Loading
core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ public function testSettingsUI(): void { ]; $this->assertSettings('comment', 'comment_article', TRUE, $edit); $entity_field_manager = \Drupal::service('entity_field.manager'); $entity_field_manager->clearCachedFieldDefinitions(); $definition = $entity_field_manager->getFieldDefinitions('comment', 'comment_article')['comment_body']; $this->assertTrue($definition->isTranslatable(), 'Article comment body is translatable.'); $definition = $entity_field_manager->getFieldDefinitions('comment', 'comment_article')['subject']; Loading
core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ public function entityBundleInfo(): array { $bundles = []; $entity_types = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_types as $entity_type_id => $entity_type) { if ($entity_type->getProvider() == 'entity_test' if (in_array($entity_type->getProvider(), ['entity_test', 'entity_test_update'], TRUE) && !in_array($entity_type_id, ['entity_test_with_bundle', 'entity_test_mul_with_bundle'], TRUE)) { $bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles', [$entity_type_id => ['label' => 'Entity Test Bundle']]); } Loading
core/modules/views/tests/src/Kernel/FieldApiDataTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,7 @@ public function testViewsData(): void { // selected by EntityFieldManagerInterface::getFieldLabels(). $this->assertEquals('GiraffeB" label (field_string)', $data[$current_table][$field_storage_string->getName() . '_value']['title']); $this->assertInstanceOf(MarkupInterface::class, $data[$current_table][$field_storage_string->getName()]['help']); $this->assertEquals('Appears in: page, article, news. Also known as: Content: GiraffeA" label', $data[$current_table][$field_storage_string->getName()]['help']); $this->assertEquals('Appears in: article, page, news. Also known as: Content: GiraffeA" label', $data[$current_table][$field_storage_string->getName()]['help']); } /** Loading
core/modules/views_ui/tests/src/Functional/HandlerTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -220,7 +220,7 @@ public function testHandlerHelpEscaping(): void { $this->drupalGet('admin/structure/views/nojs/add-handler/content/default/field'); $this->assertSession()->assertEscaped('The <em>giraffe"</em> label <script>alert("the return of the xss")</script>'); $this->assertSession()->assertEscaped('Appears in: page, article. Also known as: Content: The giraffe" label'); $this->assertSession()->assertEscaped('Appears in: article, page. Also known as: Content: The giraffe" label'); } /** Loading