TypeError: Argument 1 passed to Drupal\ckeditor5\HTMLRestrictions::__construct() must be of the type array, object given

Created on 4 May 2023, about 1 year ago
Updated 8 May 2023, about 1 year ago

Problem/Motivation

I am trying to use HTMLawed with Drupal 9 and CKEditor 5. However, when trying to configure it, this results in the following error:

TypeError: Argument 1 passed to Drupal\ckeditor5\HTMLRestrictions::__construct() must be of the type array, object given, called in /var/lib/tugboat/stm/web/core/modules/ckeditor5/src/Plugin/Validation/Constraint/FundamentalCompatibilityConstraintValidator.php on line 156 in Drupal\ckeditor5\HTMLRestrictions->__construct() (line 82 of /var/lib/tugboat/stm/web/core/modules/ckeditor5/src/HTMLRestrictions.php)

#0 /var/lib/tugboat/stm/web/core/modules/ckeditor5/src/Plugin/Validation/Constraint/FundamentalCompatibilityConstraintValidator.php(156): Drupal\ckeditor5\HTMLRestrictions->__construct(Object(Drupal\ckeditor5\HTMLRestrictions))
#1 /var/lib/tugboat/stm/web/core/modules/ckeditor5/src/Plugin/Validation/Constraint/FundamentalCompatibilityConstraintValidator.php(79): Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator->checkHtmlRestrictionsMatch(Object(Drupal\editor\Entity\Editor), Object(Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraint))
#2 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(201): Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator->validate(Array, Object(Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraint))
#3 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(153): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints(Array, '0000000020d2a7a...', Array)
#4 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(105): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object(Drupal\Core\Config\Schema\Mapping), Array, true)
#5 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php(93): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate(Object(Drupal\Core\Config\Schema\Mapping), NULL, NULL)
#6 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/TypedData/TypedData.php(132): Drupal\Core\TypedData\Validation\RecursiveValidator->validate(Object(Drupal\Core\Config\Schema\Mapping))
#7 /var/lib/tugboat/stm/web/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php(236): Drupal\Core\TypedData\TypedData->validate()
#8 /var/lib/tugboat/stm/web/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php(680): Drupal\ckeditor5\Plugin\Editor\CKEditor5::validatePair(Object(Drupal\editor\Entity\Editor), Object(Drupal\filter\Entity\FilterFormat))
#9 /var/lib/tugboat/stm/web/core/modules/editor/editor.module(211): Drupal\ckeditor5\Plugin\Editor\CKEditor5->validateConfigurationForm(Array, Object(Drupal\Core\Form\SubformState))
#10 [internal function]: editor_form_filter_admin_format_validate(Array, Object(Drupal\Core\Form\FormState))
#11 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array('editor_form_fil...', Array)
#12 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/Form/FormValidator.php(275): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
#13 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'filter_format_e...')
#14 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/Form/FormBuilder.php(591): Drupal\Core\Form\FormValidator->validateForm('filter_format_e...', Array, Object(Drupal\Core\Form\FormState))
#15 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/Form/FormBuilder.php(323): Drupal\Core\Form\FormBuilder->processForm('filter_format_e...', Array, Object(Drupal\Core\Form\FormState))
#16 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\filter\FilterFormatEditForm), Object(Drupal\Core\Form\FormState))
#17 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#18 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#19 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#21 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#22 /var/lib/tugboat/stm/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#23 /var/lib/tugboat/stm/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#24 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /var/lib/tugboat/stm/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /var/lib/tugboat/stm/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /var/lib/tugboat/stm/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /var/lib/tugboat/stm/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /var/lib/tugboat/stm/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#33 {main}

Steps to reproduce

- Set-up a fresh Drupal (9.5.8) installation
- Enable htmLawed (4.1.3)
- Add a new text format (/admin/config/content/formats/add)
- Select "CKEditor 5" as text editor
- Remove everything from the toolbar except the "Bold" (B) icon
- Enable the htmLawed filter
- Enable the "Limit allowed HTML tags and correct faulty HTML" filter
- Use the following htmLawed config:

'safe' => 1, 'elements' =>'br,p,strong'

- Hit "Save configuration"
- Error appears

πŸ› Bug report
Status

Closed: works as designed

Version

4.1

Component

Code

Created by

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

Comments & Activities

Production build 0.69.0 2024