Problem/Motivation

Discovered while working on #3245320: Automatic upgrade path always disables image uploads — in the UI.

Root cause:
editor_form_filter_admin_format_editor_configure() does

    elseif (empty($editor) || $editor_value !== $editor->getEditor()) {
      $format = $form_state->getFormObject()->getEntity();
      $editor = Editor::create([
          'format' => $format->isNew() ? NULL : $format->id(),
        'editor' => $editor_value,
      ]);
      $form_state->set('editor', $editor);
    }

It's that second condition that allows entering this branch that is true when switching the text editor. While text-editor specific settings cannot be carried over, image upload settings can be, because they're embedded in the Editor config entity at the top-level, and they even have an API interface: \Drupal\editor\EditorInterface::getImageUploadSettings() + \Drupal\editor\EditorInterface::setImageUploadSettings().

Steps to reproduce

Switch the default Basic HTML text format to use CKEditor 5 and observe the image uploads setting getting turned off.

Proposed resolution

Carry over image upload settings when switching text editor.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Issue summary: View changes
wim leers’s picture

Status: Active » Needs review
StatusFileSize
new681 bytes
wim leers’s picture

Title: Switching text editors always disables image uploads, because image upload settings are not carried over » [PP-1] Switching text editors always disables image uploads, because image upload settings are not carried over
Assigned: Unassigned » wim leers
Status: Needs review » Postponed

Note: when CKEditor 5 is in Drupal core, we can rely on the test coverage that #3245320: Automatic upgrade path always disables image uploads — in the UI is adding: we can then first remove the work-around that was added there, observe the test failing, and then add this more generic fix instead.

So, postponing on #3231364: Add CKEditor 5 module to Drupal core.

Wim Leers credited lauriii.

wim leers’s picture

Title: [PP-1] Switching text editors always disables image uploads, because image upload settings are not carried over » Should switching text editors retain image upload settings?
Assigned: wim leers » Unassigned
Status: Postponed » Active
Issue tags: +Needs issue summary update

Realized this wasn't quite right yet after digging into this with @lauriii 😅

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new685 bytes
new679 bytes

Status: Needs review » Needs work

The last submitted patch, 10: 3245351-10.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new667 bytes
new677 bytes

Status: Needs review » Needs work

The last submitted patch, 12: 3245351-12.patch, failed testing. View results

wim leers’s picture

Assigned: Unassigned » wim leers

One legitimate failure remains:

1) Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5AllowedTagsTest::testEnablingToVersion5Validation
Confirm new text format saved
Failed asserting that false is true.

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:121
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55
/var/www/html/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5TestBase.php:84
/var/www/html/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php:80
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:726

Will investigate.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

Assigned: wim leers » Unassigned
Priority: Normal » Minor

Not important enough.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.