Closed (fixed)
Project:
UI Styles
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Aug 2024 at 15:34 UTC
Updated:
29 Sep 2024 at 14:59 UTC
Jump to comment: Most recent
So I am testing UI Patterns 2 with UI Styles for #3464894: [2.0.0-beta2] Drag & drop support in layout builder.
When adding styles in Layout Builder, I obtained the following fatal error:
TypeError: Drupal\ui_styles\Render\TrustedCallbackWrapper::doTrustedCallback(): Argument #1 ($callback) must be of type callable, string given, called in /project/app/modules/contrib/ui_styles/src/Render/Element.php on line 268 in Drupal\ui_styles\Render\TrustedCallbackWrapper->doTrustedCallback() (line 57 of core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).
Drupal\ui_styles\Render\Element::doCallback('#pre_render', 'ui_patterns_library.component_element_alter:alter', Array) (Line: 196)
Drupal\ui_styles\Render\Element::isRenderElementAcceptingAttributes(Array) (Line: 135)
Drupal\ui_styles\Render\Element::isAcceptingAttributes(Array) (Line: 88)
Drupal\ui_styles\Render\Element::wrapElementIfNotAcceptingAttributes(Array) (Line: 326)
Drupal\ui_styles\StylePluginManager->addClasses(Array, Array, Array) (Line: 115)
Drupal\ui_styles_layout_builder\HookHandler\EntityViewAlter->addStylesToSection(Array, Object, 0) (Line: 96)
Drupal\ui_styles_layout_builder\HookHandler\EntityViewAlter->alter(Array, Object, Object) (Line: 36)
ui_styles_layout_builder_entity_view_alter(Array, Object, Object) (Line: 552)
Drupal\Core\Extension\ModuleHandler->alter('node_view', Array, Object, Object) (Line: 305)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func_array(Array, Array) (Line: 113)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 870)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 432)
Transform pre_render insertion into proper callable syntax.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
grimreaperIf a service is injected then, there is a serialization problem.
Can the alter method of modules/ui_patterns_library/src/Element/ComponentElementAlter.php be transformed into static. Then I guess no more need that it to be a service.
Comment #3
pdureau commentedChristian is the one who built the ComponentElementAlter architecture:
hook_element_info_alterwith some tricky logic about order of execution:So, let's check with him what can be done, and it would be better to keep the 3 with similar structure & mechanisms .
By the way, it is OK to modify
modules/ui_patterns_library/src/Element/ComponentElementAlter.phpbecause it is stable, but most of theui_patterns_librarywill be totally revamped for beta2.Comment #4
pdureau commentedChristian, can you answer to Florent?
Comment #5
pdureau commentedComment #6
pdureau commentedComment #7
pdureau commentedComment #8
pdureau commentedComment #9
pdureau commentedOne month after Florent has created this ticket, I am doing the same tests.
I don't meet the
TypeError: Argument #1 ($callback) must be of type callable, string givenor any other fatal error.But the styles are not applied.
For example, if I create a section with Bootstrap
alertcomponent as a layout and I apply thebg-dangerstyle utility to theheadingslot, I see the style inside the region (so a temporary place sued by the layout PAI) and not inside the component slot (what will be rendered using SDC):But this fix (which is the same #3464894: [2.0.0-beta2] Drag & drop support in layout builder, with only one line more) seems to work:
Florent, I give the ticket back to you to check my analysis.
Comment #10
grimreaperHello,
As seen together, I still reproduce the problem on my env with Core 10.3.3 and latest dev version of UI Patterns 2.
Comment #11
pdureau commentedI am not reproducing with drupal 11.0
I will test with drupal 10.3
Comment #12
pdureau commentedI am still not reproducing.
Here is my 10.2 install
With up-to-date UI Patterns 2
Comment #13
grimreaperWe investigated with @pdureau.
Core is calling pre_renders with special handling which make it work.
The light way UI Styles is using to trigger pre_renders should reproduce this handling or call directly Core services/methods.
Comment #15
grimreaperComment #17
grimreaperMerged for UI Styles, I will do a release.
In needs review for UI Patterns.
Comment #19
pdureau commentedComment #20
pdureau commentedUI Patterns MR is OK: https://git.drupalcode.org/project/ui_patterns/-/merge_requests/208/diffs
Comment #21
grimreaper