diff -u b/core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php b/core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php --- b/core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php +++ b/core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php @@ -71,15 +71,6 @@ $entity->name->value = $this->randomMachineName(); $entity->save(); - // Test constraint failure. - $entity_fail = $storage->create(); - $entity_fail->summary_field->value = $this->randomMachineName(); - $entity_fail->summary_field->summary = $this->randomMachineName(); - $entity_fail->summary_field->format = 'failure_format'; - $entity_fail->name->value = $this->randomMachineName(); - $violations = $entity_fail->validate(); - $this->assertCount(2, $violations); - $entity = $storage->load($entity->id()); $this->assertInstanceOf(FieldItemListInterface::class, $entity->summary_field); $this->assertInstanceOf(FieldItemInterface::class, $entity->summary_field[0]); reverted: --- b/core/modules/text/text.install +++ /dev/null @@ -1,31 +0,0 @@ -update($sandbox, 'field_config', function (FieldConfigInterface $field_config) { - $class = get_class($field_config); - // Deal only with text fields and descendants. - if ($class == TextItemBase::class || is_subclass_of($class, TextItemBase::class)) { - // Get the existing allowed_formats setting. - $allowed_formats = $field_config->get('settings.allowed_formats'); - if (!is_array($allowed_formats) && empty($allowed_formats)) { - // Save default value if existing value not present. - $field_config->set('settings.allowed_formats', []); - } - return TRUE; - } - return FALSE; - }); -} only in patch2: unchanged: --- a/core/modules/text/text.post_update.php +++ b/core/modules/text/text.post_update.php @@ -8,6 +8,8 @@ use Drupal\Core\Config\Entity\ConfigEntityUpdater; use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\text\Plugin\Field\FieldWidget\TextareaWithSummaryWidget; +use Drupal\text\Plugin\Field\FieldType\TextItemBase; +use Drupal\field\FieldConfigInterface; /** * Implements hook_removed_post_updates(). @@ -46,3 +48,24 @@ function text_post_update_add_required_summary_flag_form_display(&$sandbox = NUL $config_entity_updater->update($sandbox, 'entity_form_display', $widget_callback); } + +/** + * Add allowed_formats setting to existing text fields. + */ +function test_post_update_allowed_formats(&$sandbox = NULL) { + \Drupal::classResolver(ConfigEntityUpdater::class) + ->update($sandbox, 'field_config', function (FieldConfigInterface $field_config) { + $class = get_class($field_config); + // Deal only with text fields and descendants. + if ($class == TextItemBase::class || is_subclass_of($class, TextItemBase::class)) { + // Get the existing allowed_formats setting. + $allowed_formats = $field_config->get('settings.allowed_formats'); + if (!is_array($allowed_formats) && empty($allowed_formats)) { + // Save default value if existing value not present. + $field_config->set('settings.allowed_formats', []); + } + return TRUE; + } + return FALSE; + }); +}