--- 784672-145-allow_text_format.patch 2019-07-15 17:29:56.378109293 +0300 +++ 784672-152.patch 2019-07-15 17:41:45.626171376 +0300 @@ -1,8 +1,8 @@ diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module -index 98f0925ab9..69a47e58a9 100644 +index 6b9446b..b120482 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module -@@ -86,7 +86,10 @@ function block_content_add_body_field($block_type_id, $label = 'Body') { +@@ -87,7 +87,10 @@ function block_content_add_body_field($block_type_id, $label = 'Body') { 'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'), 'bundle' => $block_type_id, 'label' => $label, @@ -15,7 +15,7 @@ $field->save(); diff --git a/core/modules/block_content/migrations/block_content_body_field.yml b/core/modules/block_content/migrations/block_content_body_field.yml -index 9ed884f99e..bc30e0ff98 100644 +index 9ed884f..bc30e0f 100644 --- a/core/modules/block_content/migrations/block_content_body_field.yml +++ b/core/modules/block_content/migrations/block_content_body_field.yml @@ -13,6 +13,7 @@ source: @@ -27,20 +27,20 @@ entity_type: type: string diff --git a/core/modules/book/config/optional/field.field.node.book.body.yml b/core/modules/book/config/optional/field.field.node.book.body.yml -index b97b9fa8b9..3fdd7c2d27 100644 +index 7cf998d..e45dcc2 100644 --- a/core/modules/book/config/optional/field.field.node.book.body.yml +++ b/core/modules/book/config/optional/field.field.node.book.body.yml -@@ -18,4 +18,5 @@ default_value: { } - default_value_callback: '' +@@ -19,4 +19,5 @@ default_value_callback: '' settings: display_summary: true + required_summary: false + allowed_formats: { } field_type: text_with_summary diff --git a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php -index a9ee69719b..a76a0386c2 100644 +index 1a1a5ce..4cfd503 100644 --- a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php -@@ -58,7 +58,10 @@ class CKEditorIntegrationTest extends WebDriverTestBase { +@@ -65,7 +65,10 @@ protected function setUp() { 'field_storage' => $field_storage, 'bundle' => 'page', 'label' => 'Body', @@ -53,10 +53,10 @@ ])->save(); diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php -index 1d0116dc99..2b5c77a904 100644 +index 1d0116d..2b5c77a 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php -@@ -404,7 +404,10 @@ class ConfigTranslationListUiTest extends BrowserTestBase { +@@ -404,7 +404,10 @@ public function doFieldListTest() { 'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'), 'bundle' => $block_content_type->id(), 'label' => 'Body', @@ -69,10 +69,10 @@ $field->save(); diff --git a/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php b/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php -index 40ce43f578..3abca643f3 100644 +index 40ce43f..3abca64 100644 --- a/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php +++ b/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php -@@ -82,7 +82,9 @@ abstract class FieldConfigResourceTestBase extends EntityResourceTestBase { +@@ -82,7 +82,9 @@ protected function getExpectedNormalizedEntity() { 'label' => 'field_llama', 'langcode' => 'en', 'required' => FALSE, @@ -84,10 +84,10 @@ 'translatable' => TRUE, 'uuid' => $this->entity->uuid(), diff --git a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php -index 6c4e29c4be..ff55ce7479 100644 +index 6f2ef1d..31f0b2f 100644 --- a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php +++ b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php -@@ -31,7 +31,7 @@ class MigrateFieldInstanceTest extends MigrateDrupal6TestBase { +@@ -31,7 +31,7 @@ public function testFieldInstanceMigration() { $field = FieldConfig::load('node.story.field_test'); $this->assertIdentical('Text Field', $field->label()); // field_test is a text_long field, which have no settings. @@ -97,7 +97,7 @@ // Test a number field. diff --git a/core/modules/forum/config/optional/field.field.comment.comment_forum.comment_body.yml b/core/modules/forum/config/optional/field.field.comment.comment_forum.comment_body.yml -index 215199cc22..8c6fa4c571 100644 +index 215199c..8c6fa4c 100644 --- a/core/modules/forum/config/optional/field.field.comment.comment_forum.comment_body.yml +++ b/core/modules/forum/config/optional/field.field.comment.comment_forum.comment_body.yml @@ -16,5 +16,6 @@ required: true @@ -109,20 +109,20 @@ + allowed_formats: { } field_type: text_long diff --git a/core/modules/forum/config/optional/field.field.node.forum.body.yml b/core/modules/forum/config/optional/field.field.node.forum.body.yml -index af6f7ad123..57fa67e72a 100644 +index 4289cdb..ac1fa82 100644 --- a/core/modules/forum/config/optional/field.field.node.forum.body.yml +++ b/core/modules/forum/config/optional/field.field.node.forum.body.yml -@@ -18,4 +18,5 @@ default_value: { } - default_value_callback: '' +@@ -19,4 +19,5 @@ default_value_callback: '' settings: display_summary: true + required_summary: false + allowed_formats: { } field_type: text_with_summary diff --git a/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php -index 7c9a74ab50..4a2ec33688 100644 +index 7c9a74a..4a2ec33 100644 --- a/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php +++ b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php -@@ -51,7 +51,10 @@ class FormErrorHandlerCKEditorTest extends WebDriverTestBase { +@@ -51,7 +51,10 @@ protected function setUp() { 'field_storage' => $field_storage, 'bundle' => 'page', 'label' => 'Body', @@ -135,10 +135,10 @@ ])->save(); diff --git a/core/modules/node/node.module b/core/modules/node/node.module -index 818fc899ac..451996634e 100644 +index 4560a7c..89ebc6a 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module -@@ -358,7 +358,10 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') { +@@ -363,7 +363,10 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') { 'field_storage' => $field_storage, 'bundle' => $type->id(), 'label' => $label, @@ -151,7 +151,7 @@ $field->save(); diff --git a/core/modules/options/tests/options_config_install_test/config/install/field.field.node.options_install_test.body.yml b/core/modules/options/tests/options_config_install_test/config/install/field.field.node.options_install_test.body.yml -index 2078a84485..ac288b88f3 100644 +index 2078a84..ac288b8 100644 --- a/core/modules/options/tests/options_config_install_test/config/install/field.field.node.options_install_test.body.yml +++ b/core/modules/options/tests/options_config_install_test/config/install/field.field.node.options_install_test.body.yml @@ -16,5 +16,6 @@ default_value: { } @@ -162,7 +162,7 @@ third_party_settings: { } field_type: text_with_summary diff --git a/core/modules/text/config/schema/text.schema.yml b/core/modules/text/config/schema/text.schema.yml -index dfc92cd2ba..6bc711a695 100644 +index 08bc9aad..40be366 100644 --- a/core/modules/text/config/schema/text.schema.yml +++ b/core/modules/text/config/schema/text.schema.yml @@ -19,6 +19,12 @@ field.storage_settings.text: @@ -191,10 +191,10 @@ field.value.text_long: type: mapping -@@ -61,6 +73,11 @@ field.field_settings.text_with_summary: - display_summary: +@@ -64,6 +76,11 @@ field.field_settings.text_with_summary: + required_summary: type: boolean - label: 'Summary input' + label: 'Require summary' + allowed_formats: + type: sequence + label: 'Allowed text formats' @@ -204,10 +204,10 @@ field.value.text_with_summary: type: mapping diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php -index e70fadacb1..6d8850edfb 100644 +index e70fada..6d8850e 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php -@@ -7,12 +7,38 @@ use Drupal\Core\Field\FieldDefinitionInterface; +@@ -7,6 +7,7 @@ use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\TypedData\DataDefinition; @@ -215,12 +215,10 @@ /** * Base class for 'text' configurable field types. - */ - abstract class TextItemBase extends FieldItemBase { - -+ /** -+ * {@inheritdoc} -+ */ +@@ -16,6 +17,31 @@ + /** + * {@inheritdoc} + */ + public static function defaultFieldSettings() { + return ['allowed_formats' => []] + parent::defaultFieldSettings(); + } @@ -234,23 +232,26 @@ + + $element['allowed_formats'] = [ + '#type' => 'checkboxes', -+ '#title' => t('Allowed text formats'), ++ '#title' => $this->t('Allowed text formats'), + '#options' => $this->getProperties()['format']->getPossibleOptions(), + '#default_value' => $settings['allowed_formats'], -+ '#description' => t('Select the allowed text formats. If no formats are selected, all available text formats will be displayed to the user.'), ++ '#description' => $this->t('Select the allowed text formats. If no formats are selected, all available text formats will be displayed to the user.'), + ]; + + return $element; + } + - /** - * {@inheritdoc} - */ ++ /** ++ * {@inheritdoc} ++ */ + public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { + $properties['value'] = DataDefinition::create('string') + ->setLabel(t('Text')) diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php -index 6af6d0431f..6d08bf2cf7 100644 +index 9c9a160..06fb1d9 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php -@@ -85,7 +85,7 @@ class TextWithSummaryItem extends TextItemBase { +@@ -86,7 +86,7 @@ public function isEmpty() { * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { @@ -260,10 +261,10 @@ $element['display_summary'] = [ diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php -index 69a660e4db..fc15a2bbe3 100644 +index 69a660e..fc15a2b 100644 --- a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php +++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php -@@ -34,11 +34,20 @@ class TextareaWidget extends StringTextareaWidget { +@@ -34,11 +34,20 @@ public function settingsForm(array $form, FormStateInterface $form_state) { */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $main_widget = parent::formElement($items, $delta, $element, $form, $form_state); @@ -285,7 +286,7 @@ } diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php -index af8493de08..14188e1113 100644 +index af8493d..14188e1 100644 --- a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php +++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php @@ -25,11 +25,17 @@ class TextfieldWidget extends StringTextfieldWidget { @@ -307,10 +308,10 @@ } diff --git a/core/modules/text/tests/src/Functional/TextFieldTest.php b/core/modules/text/tests/src/Functional/TextFieldTest.php -index ac01dd78a7..7bcdd9e5a2 100644 +index 489d70f..40495d0 100644 --- a/core/modules/text/tests/src/Functional/TextFieldTest.php +++ b/core/modules/text/tests/src/Functional/TextFieldTest.php -@@ -9,6 +9,7 @@ use Drupal\field\Entity\FieldStorageConfig; +@@ -9,6 +9,7 @@ use Drupal\filter\Entity\FilterFormat; use Drupal\Tests\field\Functional\String\StringFieldTest; use Drupal\Tests\TestFileCreationTrait; @@ -318,11 +319,10 @@ /** * Tests the creation of text fields. -@@ -146,6 +147,79 @@ class TextFieldTest extends StringFieldTest { - $this->_testTextfieldWidgetsFormatted('text_long', 'text_textarea'); +@@ -149,6 +150,79 @@ public function testTextfieldWidgetsFormatted() { } -+ /** + /** + * Test widgets for fields with selected allowed formats. + */ + public function testTextfieldWidgetsAllowedFormats() { @@ -395,10 +395,11 @@ + $this->assertNoFieldByName("{$field_name}[0][format]", NULL, 'Format selector is not displayed'); + } + - /** ++ /** * Helper function for testTextfieldWidgetsFormatted(). */ -@@ -187,8 +261,8 @@ class TextFieldTest extends StringFieldTest { + public function _testTextfieldWidgetsFormatted($field_type, $widget_type) { +@@ -191,8 +265,8 @@ public function _testTextfieldWidgetsFormatted($field_type, $widget_type) { // Display the creation form. Since the user only has access to one format, // no format selector will be displayed. $this->drupalGet('entity_test/add'); @@ -410,10 +411,10 @@ // Submit with data that should be filtered. $value = '' . $this->randomMachineName() . ''; diff --git a/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php b/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php -index 34f58122ca..3ce6488978 100644 +index 34f5812..3ce6488 100644 --- a/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php +++ b/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php -@@ -73,7 +73,10 @@ class ViewEntityDependenciesTest extends ViewsKernelTestBase { +@@ -73,7 +73,10 @@ protected function setUp($import_test_views = TRUE) { 'field_storage' => FieldStorageConfig::loadByName('node', 'body'), 'bundle' => $content_type->id(), 'label' => $this->randomMachineName() . '_body', @@ -426,17 +427,17 @@ ViewTestData::createTestViews(get_class($this), ['views_test_config']); diff --git a/core/profiles/demo_umami/config/install/field.field.block_content.basic.body.yml b/core/profiles/demo_umami/config/install/field.field.block_content.basic.body.yml -index 89118eff08..8f00859c1c 100644 +index dab4f98..40968da 100644 --- a/core/profiles/demo_umami/config/install/field.field.block_content.basic.body.yml +++ b/core/profiles/demo_umami/config/install/field.field.block_content.basic.body.yml -@@ -18,4 +18,5 @@ default_value: { } - default_value_callback: '' +@@ -19,4 +19,5 @@ default_value_callback: '' settings: display_summary: false + required_summary: false + allowed_formats: { } field_type: text_with_summary diff --git a/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_copyright.yml b/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_copyright.yml -index 964a88887c..30cbbdbb05 100644 +index 964a888..30cbbdb 100644 --- a/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_copyright.yml +++ b/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_copyright.yml @@ -16,5 +16,6 @@ required: false @@ -448,17 +449,17 @@ + allowed_formats: { } field_type: text_long diff --git a/core/profiles/standard/config/install/field.field.block_content.basic.body.yml b/core/profiles/standard/config/install/field.field.block_content.basic.body.yml -index 89118eff08..8f00859c1c 100644 +index dab4f98..40968da 100644 --- a/core/profiles/standard/config/install/field.field.block_content.basic.body.yml +++ b/core/profiles/standard/config/install/field.field.block_content.basic.body.yml -@@ -18,4 +18,5 @@ default_value: { } - default_value_callback: '' +@@ -19,4 +19,5 @@ default_value_callback: '' settings: display_summary: false + required_summary: false + allowed_formats: { } field_type: text_with_summary diff --git a/core/profiles/standard/config/install/field.field.comment.comment.comment_body.yml b/core/profiles/standard/config/install/field.field.comment.comment.comment_body.yml -index 1337070d16..8d97e03507 100644 +index 1337070..8d97e03 100644 --- a/core/profiles/standard/config/install/field.field.comment.comment.comment_body.yml +++ b/core/profiles/standard/config/install/field.field.comment.comment.comment_body.yml @@ -16,5 +16,6 @@ required: true @@ -470,22 +471,22 @@ + allowed_formats: { } field_type: text_long diff --git a/core/profiles/standard/config/install/field.field.node.article.body.yml b/core/profiles/standard/config/install/field.field.node.article.body.yml -index 8f3681d962..9ac4f523a2 100644 +index b36fbd5..66f00ac 100644 --- a/core/profiles/standard/config/install/field.field.node.article.body.yml +++ b/core/profiles/standard/config/install/field.field.node.article.body.yml -@@ -18,4 +18,5 @@ default_value: { } - default_value_callback: '' +@@ -19,4 +19,5 @@ default_value_callback: '' settings: display_summary: true + required_summary: false + allowed_formats: { } field_type: text_with_summary diff --git a/core/profiles/standard/config/install/field.field.node.page.body.yml b/core/profiles/standard/config/install/field.field.node.page.body.yml -index 6c09432b41..8ecd10344e 100644 +index 4ff17d0..c81d703 100644 --- a/core/profiles/standard/config/install/field.field.node.page.body.yml +++ b/core/profiles/standard/config/install/field.field.node.page.body.yml -@@ -18,4 +18,5 @@ default_value: { } - default_value_callback: '' +@@ -19,4 +19,5 @@ default_value_callback: '' settings: display_summary: true + required_summary: false + allowed_formats: { } field_type: text_with_summary