- Issue created by @juc1
- 🇫🇷France pdureau Paris
Hi Juc1, I am not reproducing. Can you share with us your display builder profile config ?
- 🇬🇧United Kingdom juc1
hi, I have not touched the profiles so it is just the default profile, same error for a block display...
- 🇬🇧United Kingdom juc1
ah the error happens with my theme - which is a sub theme of https://www.drupal.org/project/ui_suite_daisyui →
It works ok with a different theme.
- 🇫🇷France pdureau Paris
ah the error happens with my theme - which is a sub theme of https://www.drupal.org/project/ui_suite_daisyui →
Oh! that's interesting! Can you isolate the SDC which is triggering this error?
- 🇬🇧United Kingdom juc1
ok I found it, it was one of my own custom SDC that I had half finished and it was a missing "name" key in the component.yaml that triggered the error. This SDC was there for a few days so it did not cause an error before installing Display Builder but I guess that Display Builder is more sensitive. Anyway fixed, thank you...
- 🇫🇷France pdureau Paris
Thanks for the investigation.
but I guess that Display Builder is more sensitive.
Display Builder must not be more sensitive than SDC and UI Patterns, so it is something to fix.
- 🇬🇧United Kingdom juc1
It would be good if the error message (my first post, above) was more helpful such as mentioning the SDC that is causing the problem, but I am not sure if you can control the error messages.
- 🇫🇷France pdureau Paris
It would be good if the error message (my first post, above) was more helpful
It would be even better without an error message because Display Builder will not trigger errors anymore :) But if it is not possible, I agree a better error message would help.
@juc1 do you want to propose a fix yourself?
- 🇫🇷France Grimreaper France 🇫🇷
No patches or MR here, so status should be active.
- 🇬🇧United Kingdom juc1
ok I will have a go, I think the problem might be...
\display_builder\src\Plugin\display_builder\Island\ComponentLibraryPanel.php, 566
// Order list ignoring starting '(' that is used for components names that // are sub components. \uasort($filtered_definitions, static function ($a, $b) { // @phpstan-ignore-next-line $nameA = \ltrim($a['name'] ?? $a['label'], '(');
- 🇬🇧United Kingdom juc1
On a quick test this patch seems to fix the problem for me...
When the Component Library Panel is built, the list of SDCs is sorted alphabetically by the component's "name" key. The ltrim() function is used during this sort process.
If an SDC is missing its name key, ComponentLibraryPanel.php falls back to using the component's label, which is a TranslatableMarkup object. The ltrim() function expects a string, so passing an object instead of a string causes a fatal error.
This patch converts the value to a string before it is passed to the ltrim() function. This ensures the ltrim() function always receives the correct data type and prevents the error, allowing the component library to load gracefully.
- @juc1 opened merge request.
- 🇫🇷France pdureau Paris
The problem exists in other parts of Display Builder, so fixing it in
Argument #4 ($title) must be of type string, Drupal\Core\StringTranslation\TranslatableMarkup given, called in /home/pierre/Projects/Drupal/ui_patterns_2/web/modules/custom/display_builder/src/Plugin/display_builder/Island/BuilderPanel.php on line 173 in Drupal\display_builder\HtmxEvents->onInstanceClick() (line 204 of modules/custom/display_builder/src/HtmxEvents.php).
I keep it in my side for now to decide if the fix must be done in Display Builder or UI Patterns 2 side.
- 🇫🇷France pdureau Paris
Moved to UI Patterns: 🐛 [2.0.7] Fix callback name fallback Active