TypeError: Drupal\ckeditor5\HTMLRestrictions::__construct(): Argument #1 ($elements) must be of type array, Drupal\ckeditor5\HTMLRestrictions given

Created on 13 December 2022, about 2 years ago
Updated 12 September 2024, 3 months ago

Problem/Motivation

When multiple filters of the type "FilterInterface::TYPE_HTML_RESTRICTOR" are enabled in CKEditor5, the site crashes with an error.

TypeError: Drupal\ckeditor5\HTMLRestrictions::__construct(): Argument #1 ($elements) must be of type array, Drupal\ckeditor5\HTMLRestrictions given, called in /app/web/core/modules/ckeditor5/src/Plugin/Validation/Constraint/FundamentalCompatibilityConstraintValidator.php on line 157 in Drupal\ckeditor5\HTMLRestrictions->__construct() (line 82 of core/modules/ckeditor5/src/HTMLRestrictions.php).

Steps to reproduce

Enable the FilerHTML plugin for CKEditor5 and another plugin of the type TYPE_HTML_RESTRICTOR. In my case it was a custom filter but you can use another module, like extend_html_filter (I know they are basically the same, but I needed another plugin of this type to reproduce).
When you save the text format, the error above appears.

Proposed resolution

The error is caused by the fact that the "provided" variable is overwritten. It is first an array with allowed HTML tags and attributes, but in the foreach loop that passes through all restrictor filters the variable is overwritten by a HTMLRestrictions instance.

๐Ÿ› Bug report
Status

Fixed

Version

10.0 โœจ

Component
CKEditor 5ย  โ†’

Last updated 1 day ago

Created by

๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Web-Beest

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024