- Issue created by @aduthois
- Status changed to Postponed: needs info
about 1 year ago 7:57pm 19 December 2023 - 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Are you able to reproduce this with vanilla Drupal core?
Can you please provide steps to reproduce starting f from install Drupal?
Thanks
- 🇬🇧United Kingdom longwave UK
The extra
[]
was added in 📌 Allow for deletion of a single value of a multiple value field Fixed but not sure how to reproduce the issue. - 🇵🇭Philippines danielhonrade
I am having the same problem, I don't know why because a vanilla Drupal install didn't get that error, but adding an override of that function and making [] to ' ' fixed it.
Are you using Bootsrap theme? May be a duplicate of 🐛 PHP error when form has entity reference in Drupal 10.2.0 RTBC .
Yes, Patch Issues-3409370-PHP-error-when-form-has-entity-reference.patch
solve the problem but for me is a core problem not bootstrap theme problem :
function template_preprocess_field_multiple_value_form add a empty array, why ?- Status changed to Active
12 months ago 6:51pm 8 January 2024 @larowlan - steps to reproduce using Bootstrap theme are described in 🐛 PHP error when form has entity reference in Drupal 10.2.0 RTBC , reproduced here:
- Drupal 10.2.0 standard install profile with bootstrap 3.29.
- Ensure bootstrap theme active for creating content - either login as a non-admin user or disable Use the administration theme when editing or creating content at
/admin/appearance
. - Edit the article structure to add a new field:
- Label = Users
- Field type = Reference
- Reference type = User
- Rest as default
- Add article content (
/node/add/article
) - page loads OK. - Go back to the Users field settings and set the Allowed number of values to a value > 1 or Unlimited.
- Add article content (
/node/add/article
) - page fails to load and PHP error is observed in log.
To @aduthois' point - is this considered a core issue or should the fix be in Bootstrap?
- Status changed to Postponed: needs info
12 months ago 7:14am 9 January 2024 I suppose if drupal core has a good reason to add an empty array, boostrap should adapt to the case. So ok for this patch
- Status changed to Needs review
11 months ago 8:35pm 22 January 2024 - 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
I am having this problem.
The documentation for
template_preprocess_table()
says that the array values in the#header
property need to be either a string or an array with certain keys. An empty array is not consistent with the documentation. Correcting it makes sense for this reason. The attached patch does this and fixes the issue for me. - last update
11 months ago 25,852 pass, 1,780 fail - 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
There is an underlying issue here as well: As it is, there is an empty
th
element created. That shouldn't be. One option would be to give the column a title, perhaps "Actions". Another would be to remove the cell and increase thecolspan
of the previous one; see this patch for implementation. - last update
11 months ago Build Successful - Status changed to Needs work
11 months ago 2:22pm 25 January 2024 - 🇺🇸United States smustgrave
Recommend using an MR, as DrupalCI is less supported and may not be as accurate in my opinion.
But currently the patch is showing failures.
Also will need test coverage
Issue summary should be updated with standard template. Added the template but will have to be updated.
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
I have created a merge request with the patches.
Hi! Comment #10: drupal-header_array_empty-3409752-10.patch works for me. Thanks!
- 🇫🇷France hdnag
Hello,
I have the same issue but for D9.5.11 :
The patches are non applicables. Do you have an idea to solve that issue ?TypeError: strlen(): Argument #1 ($string) must be of type string, array given in strlen() (line 477 of core/lib/Drupal/Component/Utility/Unicode.php).
strlen(Array) (Line: 477)
Drupal\Component\Utility\Unicode::validateUtf8(Array) (Line: 65)
Drupal\Component\Utility\Xss::filter(Array, Array) (Line: 753)
Drupal\Core\Render\Renderer->ensureMarkupIsSafe(Array) (Line: 380)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 50)
__TwigTemplate_2521555a241b9ba0b3f8cdba9a2b0ebc->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('core/themes/claro/templates/form-element-label.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('form_element_label', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 60)
__TwigTemplate_661ab2f707079e55824bbaecf556a958->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('core/themes/claro/templates/form-element.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('form_element', Array) (Line: 489)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 89)
__TwigTemplate_683f4aab1c1850ba7b0b2ff00cc5518b->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('core/themes/claro/templates/form/field-multiple-value-form.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('field_multiple_value_form', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 179)
__TwigTemplate_5bcd06882cab0ed5e3210b27209930bc->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('core/themes/claro/templates/classy/dataset/table.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('table', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 56)
__TwigTemplate_683f4aab1c1850ba7b0b2ff00cc5518b->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('core/themes/claro/templates/form/field-multiple-value-form.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('field_multiple_value_form', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 44)
__TwigTemplate_a452e371f89bc4dde9344d99b72c7065->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('core/themes/claro/templates/node-edit-form.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('node_edit_form', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 130)
Drupal\cdn\StackMiddleware\DuplicateContentPreventionMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19) - 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
@hdnag your issue must be caused by something else. This issue is about a bug introduced in Drupal 10.2. Drupal 9 in no longer supported.
@Liam Morland, thanks #10 in my case resolves the bug.
@smustgrave, is there anything else (test coverage?) that is needed to get this issue across the line?
Many thanks.- First commit to issue fork.
- 🇮🇳India fatima2345
Same error occurs with bootsrap5 theme.Above patches didnt work for me .Is there any other way to fix in bootstrap5
"TypeError: strlen(): Argument #1 ($string) must be of type string, array given in strlen() (line 395 of core/lib/Drupal/Component/Utility/Unicode.php)."