diff --git a/core/modules/ckeditor5/ckeditor5.module b/core/modules/ckeditor5/ckeditor5.module index 561795fa958175d6f562f814840ab6e3de005d79..0c6c44938d8fa767193a630a863ed768fd695e31 100644 --- a/core/modules/ckeditor5/ckeditor5.module +++ b/core/modules/ckeditor5/ckeditor5.module @@ -22,9 +22,6 @@ use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; -use Drupal\editor\EditorInterface; - -// cspell:ignore multiblock /** * Implements hook_help(). @@ -624,79 +621,3 @@ function _ckeditor5_theme_css($theme = NULL): array { } return $css; } - -/** - * Implements hook_ENTITY_TYPE_presave() for editor entities. - */ -function ckeditor5_editor_presave(EditorInterface $editor) { - if ($editor->getEditor() === 'ckeditor5') { - $settings = $editor->getSettings(); - // @see ckeditor5_post_update_code_block() - if (in_array('codeBlock', $settings['toolbar']['items'], TRUE) && !isset($settings['plugins']['ckeditor5_codeBlock'])) { - // @see \Drupal\ckeditor5\Plugin\CKEditor5Plugin\CodeBlock::defaultConfiguration() - $settings['plugins']['ckeditor5_codeBlock'] = [ - 'languages' => [ - ['label' => 'Plain text', 'language' => 'plaintext'], - ['label' => 'C', 'language' => 'c'], - ['label' => 'C#', 'language' => 'cs'], - ['label' => 'C++', 'language' => 'cpp'], - ['label' => 'CSS', 'language' => 'css'], - ['label' => 'Diff', 'language' => 'diff'], - ['label' => 'HTML', 'language' => 'html'], - ['label' => 'Java', 'language' => 'java'], - ['label' => 'JavaScript', 'language' => 'javascript'], - ['label' => 'PHP', 'language' => 'php'], - ['label' => 'Python', 'language' => 'python'], - ['label' => 'Ruby', 'language' => 'ruby'], - ['label' => 'TypeScript', 'language' => 'typescript'], - ['label' => 'XML', 'language' => 'xml'], - ], - ]; - } - - // @see ckeditor5_post_update_list_multiblock() - if (array_key_exists('ckeditor5_list', $settings['plugins']) && !array_key_exists('properties', $settings['plugins']['ckeditor5_list'])) { - // Update to the new config structure. - $settings['plugins']['ckeditor5_list'] = [ - 'properties' => $settings['plugins']['ckeditor5_list'], - 'multiBlock' => TRUE, - ]; - } - - // @see ckeditor5_post_update_list_start_reversed() - if (in_array('numberedList', $settings['toolbar']['items'], TRUE) && array_key_exists('ckeditor5_sourceEditing', $settings['plugins'])) { - $source_edited = HTMLRestrictions::fromString(implode(' ', $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'])); - $format_restrictions = HTMLRestrictions::fromTextFormat($editor->getFilterFormat()); - - // If <ol start> is not allowed through Source Editing (the only way it - // could possibly be supported until now), and it is not an unrestricted - // text format (such as "Full HTML"), then set the new "startIndex" - // setting for the List plugin to false. - // Except … that this update path was added too late, and many sites have - // in the meantime edited their text editor configuration through the UI, - // in which case they may already have set it. If that is the case: do not - // override it. - $ol_start = HTMLRestrictions::fromString('<ol start>'); - if (!array_key_exists('ckeditor5_list', $settings['plugins']) || !array_key_exists('startIndex', $settings['plugins']['ckeditor5_list']['properties'])) { - $settings['plugins']['ckeditor5_list']['properties']['startIndex'] = $ol_start->diff($source_edited) - ->allowsNothing() || $format_restrictions->isUnrestricted(); - } - // Same for <ol reversed> and "reversed". - $ol_reversed = HTMLRestrictions::fromString('<ol reversed>'); - if (!array_key_exists('ckeditor5_list', $settings['plugins']) || !array_key_exists('reversed', $settings['plugins']['ckeditor5_list']['properties'])) { - $settings['plugins']['ckeditor5_list']['properties']['reversed'] = $ol_reversed->diff($source_edited) - ->allowsNothing() || $format_restrictions->isUnrestricted(); - } - // Match the sort order in ListPlugin::defaultConfiguration(). - ksort($settings['plugins']['ckeditor5_list']['properties']); - - // Update the Source Editing configuration too. - $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'] = $source_edited - ->diff($ol_start) - ->diff($ol_reversed) - ->toCKEditor5ElementsArray(); - } - - $editor->setSettings($settings); - } -} diff --git a/core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml b/core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml index 63a9d91c7de26f9451fef6812dd1bbf755144fd5..04cade0748797e7aae234870ae396ece5629a0a6 100644 --- a/core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml +++ b/core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml @@ -45,7 +45,7 @@ image_upload: status: true scheme: public directory: inline-images - max_size: '' + max_size: null max_dimensions: - width: 0 - height: 0 + width: null + height: null diff --git a/core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.full_html.yml b/core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.full_html.yml index cb86b871d3d50b2717d5fa8ef1048b22560a8d6b..82bda54faa93142dfa7b781dfd658e0e49c2b2b1 100644 --- a/core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.full_html.yml +++ b/core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.full_html.yml @@ -53,7 +53,7 @@ image_upload: status: true scheme: public directory: inline-images - max_size: '' + max_size: null max_dimensions: - width: 0 - height: 0 + width: null + height: null diff --git a/core/modules/ckeditor5/tests/src/Functional/AddedStylesheetsTest.php b/core/modules/ckeditor5/tests/src/Functional/AddedStylesheetsTest.php index 10da3a628ff8feede2b8948d370615a0b98947b7..970aaf86175f0b65637e6e210ae87e175d6f15de 100644 --- a/core/modules/ckeditor5/tests/src/Functional/AddedStylesheetsTest.php +++ b/core/modules/ckeditor5/tests/src/Functional/AddedStylesheetsTest.php @@ -62,6 +62,9 @@ protected function setUp(): void { $this->editor = Editor::create([ 'format' => 'llama', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => [], diff --git a/core/modules/ckeditor5/tests/src/Functional/ImageUploadAccessTest.php b/core/modules/ckeditor5/tests/src/Functional/ImageUploadAccessTest.php index 65cd4b16e4c3115aa3580b126ddf68d5ec3b0e57..17854a89cb28de75171b2aa2996acdebfd81b03f 100644 --- a/core/modules/ckeditor5/tests/src/Functional/ImageUploadAccessTest.php +++ b/core/modules/ckeditor5/tests/src/Functional/ImageUploadAccessTest.php @@ -37,10 +37,10 @@ public function testCkeditor5ImageUploadRoute() { 'status' => TRUE, 'scheme' => 'public', 'directory' => 'inline-images', - 'max_size' => '', + 'max_size' => NULL, 'max_dimensions' => [ - 'width' => 0, - 'height' => 0, + 'width' => NULL, + 'height' => NULL, ], ])->save(); $response = $this->uploadRequest($url, $test_image, 'test.jpg'); diff --git a/core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php b/core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php index 44e55cc22765e9f38b3a16d86a2b4e48c2a0210d..a4303e8fc4eac5fd31f554ed5989046022dce100 100644 --- a/core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php +++ b/core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php @@ -66,10 +66,10 @@ public function testUploadFileExtension() { 'status' => TRUE, 'scheme' => 'public', 'directory' => 'inline-images', - 'max_size' => '', + 'max_size' => NULL, 'max_dimensions' => [ - 'width' => 0, - 'height' => 0, + 'width' => NULL, + 'height' => NULL, ], ]); @@ -94,8 +94,8 @@ public function testFileUploadLargerFileSize() { 'directory' => 'inline-images', 'max_size' => 30000, 'max_dimensions' => [ - 'width' => 0, - 'height' => 0, + 'width' => NULL, + 'height' => NULL, ], ]); @@ -128,8 +128,8 @@ public function testLockAfterFailedValidation() { 'directory' => 'inline-images', 'max_size' => 30000, 'max_dimensions' => [ - 'width' => 0, - 'height' => 0, + 'width' => NULL, + 'height' => NULL, ], ]); diff --git a/core/modules/ckeditor5/tests/src/Functional/MediaEntityMetadataApiTest.php b/core/modules/ckeditor5/tests/src/Functional/MediaEntityMetadataApiTest.php index 8df587a4373f2e54f6e0f54f13652330f59773e1..8ab999fe22b62d41822e9bffc1c10dacddc4ceb7 100644 --- a/core/modules/ckeditor5/tests/src/Functional/MediaEntityMetadataApiTest.php +++ b/core/modules/ckeditor5/tests/src/Functional/MediaEntityMetadataApiTest.php @@ -139,6 +139,9 @@ protected function setUp(): void { $this->editor = Editor::create([ 'format' => 'filtered_html', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => [], diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php index 65db1989a6497068867f2b4c9e3494c73c2351ba..efa8ffa0825b56c932a66b2c62f7f9a639ed3b38 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php @@ -96,10 +96,10 @@ public function testImageUploadsRemainEnabled(): void { 'status' => TRUE, 'scheme' => 'public', 'directory' => 'inline-images', - 'max_size' => '', + 'max_size' => NULL, 'max_dimensions' => [ - 'width' => 0, - 'height' => 0, + 'width' => NULL, + 'height' => NULL, ], ], ])->save(); diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php index 829a67d9106bc38b13a21e835394b169f77223d5..51447052f3781fe55245d0eb22235219e492b191 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php @@ -42,6 +42,9 @@ public function testCKEditor5FocusInTooltipsInDialog() { Editor::create([ 'format' => 'test_format', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => ['link'], diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5FragmentLinkTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5FragmentLinkTest.php index 657cd98ca7b009030651eb2eeb23a39d6f45fd33..0e446e4e4263dad8560b54fe2c020aab130192ab 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5FragmentLinkTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5FragmentLinkTest.php @@ -57,6 +57,9 @@ protected function setUp(): void { Editor::create([ 'format' => 'ckeditor5', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ])->save(); // Create a node type for testing. diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php index c6feb3b2b70e7d2db92a2e7cd0398dce8b342df0..2d0f8068734c7c9c07a094907b284a73e4c41490 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php @@ -94,7 +94,7 @@ public function testAttributeEncoding() { 'status' => TRUE, 'scheme' => 'public', 'directory' => 'inline-images', - 'max_size' => '', + 'max_size' => NULL, 'max_dimensions' => [ 'width' => NULL, 'height' => NULL, @@ -637,6 +637,9 @@ public function testListPlugin() { Editor::create([ 'format' => 'test_format', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => ['sourceEditing', 'numberedList'], @@ -775,6 +778,9 @@ public function testComments(): void { Editor::create([ 'format' => 'ckeditor5', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ])->save(); $this->assertSame([], array_map( function (ConstraintViolation $v) { @@ -905,6 +911,9 @@ public function testStylesAndScripts(): void { Editor::create([ 'format' => 'ckeditor5', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => [ @@ -957,6 +966,9 @@ public function testSave(): void { Editor::create([ 'format' => 'ckeditor5', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => [ @@ -987,6 +999,9 @@ function (ConstraintViolation $v) { Editor::create([ 'format' => 'ckeditor5_2', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ])->save(); $this->assertSame([], array_map( function (ConstraintViolation $v) { diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ToolbarTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ToolbarTest.php index 434b7d966f9c6d13029ee21021c12f88817399f7..8b84878ed74e19507374175a334c3ea3af2e1e8d 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ToolbarTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ToolbarTest.php @@ -54,6 +54,9 @@ protected function setUp(): void { Editor::create([ 'editor' => 'ckeditor5', 'format' => 'test_format', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [], ])->save(); $this->assertSame([], array_map( diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/EmphasisTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/EmphasisTest.php index 67916ce200eb830e96c1fa5a648f0382d1e7d2f2..f811d2fb6e1f29689e5a8cf127affa5b00063218 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/EmphasisTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/EmphasisTest.php @@ -72,6 +72,9 @@ protected function setUp(): void { Editor::create([ 'editor' => 'ckeditor5', 'format' => 'test_format', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => [ diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaLibraryTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaLibraryTest.php index dc6dc710634e02ae4c50d5bfa3f6cfd6fb5321dd..02864ee524de902349c961cf76e3bede8b512d3f 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaLibraryTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaLibraryTest.php @@ -74,6 +74,9 @@ protected function setUp(): void { Editor::create([ 'editor' => 'ckeditor5', 'format' => 'test_format', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => [ diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php index 6872c7f00778f50ad8ccbc92db91adeaa416269b..975e5810c76894978fedd0955e373511dfdb4c52 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php @@ -79,6 +79,9 @@ protected function setUp(): void { Editor::create([ 'editor' => 'ckeditor5', 'format' => 'test_format', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => [ diff --git a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php index 72b6dd7f39c3b124dacb177291956958fd090951..6d635a7f781b1840e76778d272dea4a922be15fc 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php @@ -73,6 +73,9 @@ protected function setUp(): void { Editor::create([ 'format' => 'basic_html', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ])->save(); FilterFormat::create( Yaml::parseFile('core/profiles/standard/config/install/filter.format.full_html.yml') @@ -80,6 +83,9 @@ protected function setUp(): void { Editor::create([ 'format' => 'full_html', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ])->save(); $this->manager = $this->container->get('plugin.manager.ckeditor5.plugin'); $this->typedConfig = $this->container->get('config.typed'); @@ -1057,6 +1063,9 @@ public function testProvidedElementsInvalidElementSubset(array $configured_subse $text_editor = Editor::create([ 'format' => 'dummy', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'plugins' => [ $sneaky_plugin_id => ['configured_subset' => $configured_subset], diff --git a/core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php b/core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php index 66e6e521418868677a167695b1c461ffdff91caf..711354bd5b211013c161185d565f8775ca25ae47 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php @@ -52,6 +52,9 @@ protected function setUp(): void { Editor::create([ 'format' => 'basic_html', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ])->save(); $this->installConfig(['language']); diff --git a/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php b/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php index 5967d7797f8a571a438ed596181ecce65e53c49c..353ebe95158b4d120f273d79b792a546e12b9b4b 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php @@ -116,6 +116,9 @@ protected function setUp(): void { Editor::create([ 'format' => 'minimal_ckeditor_wrong_allowed_html', 'editor' => 'ckeditor', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'rows' => [ @@ -341,6 +344,9 @@ protected function setUp(): void { Editor::create([ 'format' => 'cke4_stylescombo_span', 'editor' => 'ckeditor', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'rows' => [ @@ -403,6 +409,9 @@ public function test(string $format_id, array $filters_to_drop, array $expected_ $minimal_valid_cke5_text_editor = Editor::create([ 'format' => $format_id, 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => ['toolbar' => ['items' => []]], ]); $pre_ck5_validation_errors = $this->validatePairToViolationsArray($minimal_valid_cke5_text_editor, $text_format, FALSE); diff --git a/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php b/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php index d617d5ad23175750cc0f2916a92b5f1c6a96cc47..6550a5f0167fd2dfc66a02201d76b78596501cc3 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php @@ -1628,6 +1628,9 @@ public function testMultipleHtmlRestrictingFilters(): void { $text_editor = Editor::create([ 'format' => 'very_restricted', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ 'toolbar' => [ 'items' => [], diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index d8ec411e9aeb55e2491648aab38cf716525654b0..7e0d17c668f67b6e5b21253e2f2af10bccb1e8f2 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -8,7 +8,6 @@ use Drupal\Core\Url; use Drupal\Component\Utility\Html; use Drupal\Core\Form\SubformState; -use Drupal\editor\EditorInterface; use Drupal\editor\Entity\Editor; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; @@ -182,6 +181,9 @@ function editor_form_filter_admin_format_editor_configure($form, FormStateInterf $editor = Editor::create([ 'format' => $format->isNew() ? NULL : $format->id(), 'editor' => $editor_value, + 'image_upload' => [ + 'status' => FALSE, + ], ]); $form_state->set('editor', $editor); } @@ -624,6 +626,8 @@ function _editor_parse_file_uuids($text) { * Implements hook_ENTITY_TYPE_presave(). * * Synchronizes the editor status to its paired text format status. + * + * @todo remove in https://www.drupal.org/project/drupal/issues/3231354. */ function editor_filter_format_presave(FilterFormatInterface $format) { // The text format being created cannot have a text editor yet. @@ -646,41 +650,3 @@ function editor_filter_format_presave(FilterFormatInterface $format) { $editor->setStatus($status)->save(); } } - -/** - * Implements hook_ENTITY_TYPE_presave(). - */ -function editor_editor_presave(EditorInterface $editor) { - // @see editor_post_update_sanitize_image_upload_settings() - $image_upload_settings = $editor->getImageUploadSettings(); - // When image uploads are disabled, then none of the other key-value pairs - // make sense. - // TRICKY: the configuration system has historically stored `type: boolean` - // not as `true` and `false`, but as `1` and `0`, so use `==`, not `===`. - // @see editor_post_update_sanitize_image_upload_settings() - if (!array_key_exists('status', $image_upload_settings) || $image_upload_settings['status'] == FALSE) { - $editor->setImageUploadSettings(['status' => FALSE]); - } - else { - // When image uploads are enabled, then some of the key-value pairs need - // some conversions to comply with the config schema. Note that all these - // keys SHOULD exist, but because validation has historically been absent, - // err on the side of caution. - // @see editor_post_update_sanitize_image_upload_settings() - if (array_key_exists('directory', $image_upload_settings) && $image_upload_settings['directory'] === '') { - $image_upload_settings['directory'] = NULL; - } - if (array_key_exists('max_size', $image_upload_settings) && $image_upload_settings['max_size'] === '') { - $image_upload_settings['max_size'] = NULL; - } - if (array_key_exists('max_dimensions', $image_upload_settings)) { - if (!array_key_exists('width', $image_upload_settings['max_dimensions']) || $image_upload_settings['max_dimensions']['width'] === 0) { - $image_upload_settings['max_dimensions']['width'] = NULL; - } - if (!array_key_exists('height', $image_upload_settings['max_dimensions']) || $image_upload_settings['max_dimensions']['height'] === 0) { - $image_upload_settings['max_dimensions']['height'] = NULL; - } - } - $editor->setImageUploadSettings($image_upload_settings); - } -} diff --git a/core/modules/editor/tests/modules/editor_private_test/config/install/editor.editor.private_images.yml b/core/modules/editor/tests/modules/editor_private_test/config/install/editor.editor.private_images.yml index c5a3f9e9212da01c168b46ecec29e14196e49d02..afa6393396a2740f1847e68ca3eb35fbfae86403 100644 --- a/core/modules/editor/tests/modules/editor_private_test/config/install/editor.editor.private_images.yml +++ b/core/modules/editor/tests/modules/editor_private_test/config/install/editor.editor.private_images.yml @@ -10,8 +10,8 @@ editor: unicorn image_upload: status: true scheme: private - directory: '' - max_size: '' + directory: null + max_size: null max_dimensions: width: null height: null diff --git a/core/modules/editor/tests/src/Functional/EditorLoadingTest.php b/core/modules/editor/tests/src/Functional/EditorLoadingTest.php index 2988b323f4a9f801ddc93a439b6738706309452a..5b08b95f8eb026a89e96d1212364b4fcc61ab922 100644 --- a/core/modules/editor/tests/src/Functional/EditorLoadingTest.php +++ b/core/modules/editor/tests/src/Functional/EditorLoadingTest.php @@ -139,10 +139,6 @@ public function testLoading() { 'editor' => 'unicorn', 'image_upload' => [ 'status' => FALSE, - 'scheme' => 'public', - 'directory' => 'inline-images', - 'max_size' => '', - 'max_dimensions' => ['width' => '', 'height' => ''], ], ]); $editor->save(); @@ -190,6 +186,9 @@ public function testLoading() { $editor = Editor::create([ 'format' => 'plain_text', 'editor' => 'unicorn', + 'image_upload' => [ + 'status' => FALSE, + ], ]); $editor->save(); @@ -255,10 +254,6 @@ public function testSupportedElementTypes() { 'editor' => 'unicorn', 'image_upload' => [ 'status' => FALSE, - 'scheme' => 'public', - 'directory' => 'inline-images', - 'max_size' => '', - 'max_dimensions' => ['width' => '', 'height' => ''], ], ]); $editor->save(); @@ -290,6 +285,9 @@ public function testSupportedElementTypes() { Editor::create([ 'format' => 'full_html', 'editor' => 'trex', + 'image_upload' => [ + 'status' => FALSE, + ], ])->save(); $this->drupalGet('node/1/edit'); diff --git a/core/modules/editor/tests/src/Functional/EditorSecurityTest.php b/core/modules/editor/tests/src/Functional/EditorSecurityTest.php index eb1760be70b4821d06202c26cbe2f8a587e5125a..619fff339a4d656a19e31dd2e2f44df2814ba05b 100644 --- a/core/modules/editor/tests/src/Functional/EditorSecurityTest.php +++ b/core/modules/editor/tests/src/Functional/EditorSecurityTest.php @@ -125,6 +125,9 @@ protected function setUp(): void { $editor = Editor::create([ 'format' => 'restricted_with_editor', 'editor' => 'unicorn', + 'image_upload' => [ + 'status' => FALSE, + ], ]); $editor->save(); $format = FilterFormat::create([ @@ -145,6 +148,9 @@ protected function setUp(): void { $editor = Editor::create([ 'format' => 'restricted_plus_dangerous_tag_with_editor', 'editor' => 'unicorn', + 'image_upload' => [ + 'status' => FALSE, + ], ]); $editor->save(); $format = FilterFormat::create([ @@ -164,6 +170,9 @@ protected function setUp(): void { $editor = Editor::create([ 'format' => 'unrestricted_with_editor', 'editor' => 'unicorn', + 'image_upload' => [ + 'status' => FALSE, + ], ]); $editor->save(); diff --git a/core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php b/core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php index 2eafeb051fed5c05d12acc21d57a23aa6cb0f2db..9d9e50b14c379872f74ca4d67c36c2fa4e191e45 100644 --- a/core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php +++ b/core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php @@ -63,16 +63,19 @@ protected function createEntity() { $camelids = Editor::create([ 'format' => 'llama', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ]); $camelids ->setImageUploadSettings([ 'status' => TRUE, 'scheme' => 'public', 'directory' => 'inline-images', - 'max_size' => '', + 'max_size' => NULL, 'max_dimensions' => [ - 'width' => '', - 'height' => '', + 'width' => NULL, + 'height' => NULL, ], ]) ->save(); diff --git a/core/modules/editor/tests/src/Kernel/EditorFileUsageTest.php b/core/modules/editor/tests/src/Kernel/EditorFileUsageTest.php index 325a3b10cc17897a87866fbc5ebec756d57d4b2f..826710f04a5fd5847d5920705d163e560464ff20 100644 --- a/core/modules/editor/tests/src/Kernel/EditorFileUsageTest.php +++ b/core/modules/editor/tests/src/Kernel/EditorFileUsageTest.php @@ -56,6 +56,9 @@ protected function setUp(): void { $editor = Editor::create([ 'format' => 'filtered_html', 'editor' => 'unicorn', + 'image_upload' => [ + 'status' => FALSE, + ], ]); $editor->save(); diff --git a/core/modules/editor/tests/src/Kernel/EditorFilterIntegrationTest.php b/core/modules/editor/tests/src/Kernel/EditorFilterIntegrationTest.php index 2a39e030d914e8f68f9ebb5a4c149e5ab12244b5..c8a108d4a9c2dd2322c1d28faa3cb5d672cc95af 100644 --- a/core/modules/editor/tests/src/Kernel/EditorFilterIntegrationTest.php +++ b/core/modules/editor/tests/src/Kernel/EditorFilterIntegrationTest.php @@ -32,7 +32,13 @@ public function testTextFormatIntegration() { $format->save(); // Create a paired editor. - Editor::create(['format' => $format->id(), 'editor' => 'unicorn'])->save(); + Editor::create([ + 'format' => $format->id(), + 'editor' => 'unicorn', + 'image_upload' => [ + 'status' => FALSE, + ], + ])->save(); // Disable the text format. $format->disable()->save(); diff --git a/core/modules/editor/tests/src/Kernel/EditorManagerTest.php b/core/modules/editor/tests/src/Kernel/EditorManagerTest.php index 47034a6c6fa4024a8466a2ff1f01881de5c9e922..f57654d7b5051ee9dea1642260bee472bfc6bd16 100644 --- a/core/modules/editor/tests/src/Kernel/EditorManagerTest.php +++ b/core/modules/editor/tests/src/Kernel/EditorManagerTest.php @@ -83,6 +83,9 @@ public function testManager() { $editor = Editor::create([ 'format' => 'full_html', 'editor' => 'unicorn', + 'image_upload' => [ + 'status' => FALSE, + ], ]); $editor->save(); $this->assertSame([], $this->editorManager->getAttachments([]), 'No attachments when one text editor is enabled and retrieving attachments for zero text formats.'); diff --git a/core/modules/editor/tests/src/Kernel/EditorValidationTest.php b/core/modules/editor/tests/src/Kernel/EditorValidationTest.php index 142933a9272683a1af5cf83d416c694ec754fdca..956177d94a1fda53f6091cb5ac9f87a462c1c644 100644 --- a/core/modules/editor/tests/src/Kernel/EditorValidationTest.php +++ b/core/modules/editor/tests/src/Kernel/EditorValidationTest.php @@ -47,6 +47,9 @@ protected function setUp(): void { $this->entity = Editor::create([ 'format' => $format->id(), 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], 'settings' => [ // @see \Drupal\ckeditor5\Plugin\Editor\CKEditor5::getDefaultSettings() 'toolbar' => [ diff --git a/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditor5Test.php b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditor5Test.php index b68a9ecf653e24ea3e12c8c6ccf55414a58618b7..0cbd8ae38aeb9fdf14712a550bb713598538fefa 100644 --- a/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditor5Test.php +++ b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditor5Test.php @@ -49,6 +49,9 @@ protected function setUp(): void { Editor::create([ 'format' => 'ckeditor5', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ])->save(); // Create a node type for testing. diff --git a/core/modules/jsonapi/tests/src/Functional/EditorTest.php b/core/modules/jsonapi/tests/src/Functional/EditorTest.php index 1ee00323269348689104c5d3178557b642363134..8cd036b12ca90f50d9c552cb4a0d4ba342b692c5 100644 --- a/core/modules/jsonapi/tests/src/Functional/EditorTest.php +++ b/core/modules/jsonapi/tests/src/Functional/EditorTest.php @@ -78,16 +78,19 @@ protected function createEntity() { $camelids = Editor::create([ 'format' => 'llama', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ]); $camelids ->setImageUploadSettings([ 'status' => TRUE, 'scheme' => 'public', 'directory' => 'inline-images', - 'max_size' => '', + 'max_size' => NULL, 'max_dimensions' => [ - 'width' => '', - 'height' => '', + 'width' => NULL, + 'height' => NULL, ], ]) ->save(); @@ -190,16 +193,19 @@ protected function createAnotherEntity($key) { $entity = Editor::create([ 'format' => 'pachyderm', 'editor' => 'ckeditor5', + 'image_upload' => [ + 'status' => FALSE, + ], ]); $entity->setImageUploadSettings([ 'status' => TRUE, 'scheme' => 'public', 'directory' => 'inline-images', - 'max_size' => '', + 'max_size' => NULL, 'max_dimensions' => [ - 'width' => '', - 'height' => '', + 'width' => NULL, + 'height' => NULL, ], ])->save();