The "ckeditor5_globalAttributeDir" CKEditor 5 plugin definition has a "drupal.conditions" value that contains some unsupported condition types: "filter"

Created on 29 January 2025, 3 months ago

Problem/Motivation

In version 9, validation of the correctness of the plugin definition has been introduced.

Plugin definition DX: validate drupal.conditions 📌 Plugin definition DX: validate drupal.conditions Fixed

Unfortunately, I noticed incorrect validation messages on several separate websites. As a result, the content editing page does not work.

Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "ckeditor5_globalAttributeDir" CKEditor 5 plugin definition has a "drupal.conditions" value that contains some unsupported condition types: "filter". Only the following conditions types are supported: "toolbarItem", "imageUploadStatus", "filter", "requiresConfiguration", "plugins". in Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition->validateDrupalAspects() (line 224 of /core/modules/ckeditor5/src/Plugin/CKEditor5PluginDefinition.php).

The validation message on the one hand informs that the 'filter' type is incorrect. And on the other hand it indicates the 'filter' type as correct. This type is on the list of permitted parameters. So we are dealing with an error in the validation itself, here.

Steps to reproduce

Validation messages appear randomly. I don't know how to reproduce it, so I do not give the steps of reproduction.

Proposed resolution

Perhaps the problem is the unstable operation of the "array_diff_key" function. In the example analysed, it compares multidimensional arrays.

$unsupported_condition_types = array_keys(array_diff_key($definition['drupal']['conditions'], $supported_condition_types));

I used my own solution (patch attached). After its application, the error disappears.

-      $unsupported_condition_types = array_keys(array_diff_key($definition['drupal']['conditions'], $supported_condition_types));
+      $unsupported_condition_types = [];
+      $supported_condition_types_keys = array_keys($supported_condition_types);
+      $definition_condition_types_keys = array_keys($definition['drupal']['conditions']);
+      foreach ($definition_condition_types_keys as $key) {
+        if (!in_array($key, $supported_condition_types_keys)) {
+          $unsupported_condition_types[] = $key;
+        }
+      }

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.1 🔥

Component

ckeditor5.module

Created by

🇵🇱Poland Krzysztof Domański Poland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024