Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293910

CKEditor 4 → 5 upgrade path may trigger warnings in some edge cases, making upgrade path tests impossible

$
0
0

Problem/Motivation

⚠️ Discovered while reviewing #3312442: Make ready for ckeditor5, which is updating the ckeditor_bidi module to support CKEditor 5 and provide an automatic upgrade path.

There are two places where we do

$end = $can_access_dblog ?
…

in SmartDefaultSettings.

But only the first is preceded by $can_access_dblog = ($this->currentUser->hasPermission('access site reports') && $this->moduleHandler->moduleExists('dblog'));. The second will crashSmartDefaultSettings if the first case wasn't also hit.

This went unnoticed until now because the first case happens in this if-test:

      if (!empty($plugins_enabled) || !$source_editing_additions->allowsNothing()) {

and the second happens in this if-test:

      // Generate warning for:
      // - The addition of <p>/<br> due to them being fundamental tags.
      // - The addition of other tags/attributes previously unsupported by the
      //   format.
      if (!$missing_fundamental_tags->allowsNothing() || !empty($attributes_to_tag) || !empty($added_tags)) {

In Drupal core, the second never happens without the first also happening, because we worked hard to never run into the case of additional attributes or tags being enabled on the text format: if that were to happen, it'd mean that we wouldn't be able to granularly match the HTML enabled for CKEditor 4 plugins!

But … contrib can be different of course: it's possible that it will be less granular in its upgrade path (and hence require supporting additional tags, attributes or attribute values).

Furthermore, it's possible Drupal 9 sites using CKEditor 4 are misconfigured: if the allowed_html is not in sync with the functionality allowed by CKEditor 4, it's possible they did not notice, the upgrade to CKEditor 5 would then automatically fix things for them. Which would then also trigger this warning:

Warning: Undefined variable $can_access_dblog in Drupal\ckeditor5\SmartDefaultSettings->computeSmartDefaultSettings() (line 375 of core/modules/ckeditor5/src/SmartDefaultSettings.php)

Steps to reproduce

See test.

This bug was introduced in #3245967: Messages upon switching to CKEditor 5 are overwhelming.

Proposed resolution

Fix.

Remaining tasks

Review.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A


Viewing all articles
Browse latest Browse all 293910

Trending Articles