Needs work
Project:
Drupal core
Version:
main
Component:
layout_builder.module
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
2 Jul 2019 at 14:26 UTC
Updated:
19 Dec 2025 at 15:28 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
corn696Patch to add the render filter to the layout twigs.
Comment #3
tim.plunkettThis seems like a symptom (or duplicate) of #953034: [meta] Themes improperly check renderable arrays when determining visibility
Comment #4
corn696hmm okay the issue exist nearly 9 years. So what is the best "temporary" workaround?
I copied the layout templates to my theme and added the render filter. Is there a better solution?
Comment #6
tim.plunkettThe render filter is a good temporary solution.
Here's one possible long-term fix.
Comment #13
tim.plunkettRebased and switched to using an MR
Comment #16
javier_rey commentedAdding a patch for the 10.1.x branch.
Comment #17
tim.plunkettFixed a couple more tests
Comment #18
smustgrave commentedThank you for this! See this often with clients who aren’t great with layout builder.
Still seem to be some test failures however. Definitely keeping this on the radar
Comment #19
smustgrave commented@tim.plunkett added a condition so the sections do build in layout builder side.
Thoughts?
Comment #20
smustgrave commentedThanks. Also seemed to cause some additional test failures that I'll look at.
Comment #21
smustgrave commentedSo this additional checks seems to be the best way to cover all scenarios.
When adding a section _layout_builder isn't there.
Tried _admin_route but that caused test failures also.
Comment #22
tim.plunkettFixing merge (using rebase) to allow me to review better
Comment #23
smustgrave commented@tim.plunkett wonder if you had a chance to review?
Comment #24
tim.plunkettI'll have to re-review, the change to checking for `layout_builder_tempstore` is tricky
Comment #25
smustgrave commentedTried this out on a local project and I use drush search-api-index
But I get this error
> [error] Error while trying to render item entity:node/48:en with view mode full for search index tetra_tech: Call to a member function getOption() on null in Drupal\Core\Layout\LayoutDefault->build() (line 70 of /var/www/html/webroot/core/lib/Drupal/Core/Layout/LayoutDefault.php).
So seems all scenarios aren't caught.
Comment #27
leoenriquezp commentedAdding a patch for the 10.2.x branch
Comment #28
tonibarbera commentedRerolled the patch for the 10.3.1 branch
Comment #29
krishna mishra commentedI get same error for media on solr indexing:
[error] Error while trying to render item entity:media/XX:en with view mode search_index for search index INDEX-ABC: Call to a member function getOption() on null in Drupal\Core\Layout\LayoutDefault->build() (line 70 of web/core/lib/Drupal/Core/Layout/LayoutDefault.php).
Comment #31
bbralaComment #32
bbralaComment #33
bbralaSorry for the noise, tool a random issue to check something. Please ignore.
Comment #34
xjkwak commentedI encountered the same issue described in #29 when applying the patch from #28. The problem occurs because
\Drupal::routeMatch()->getRouteObject()returns null in non-route contexts (e.g., during Search API indexing via cron), which leads to a fatal error whengetOption()is called.To fix this, I updated the patch to use the null-safe operator, ensuring the code does not break when the route object is unavailable:
This change ensures compatibility with CLI and cron environments. I've also attached an updated patch that includes this fix. It's my first contribution to Drupal :)
Comment #35
akalam commentedRerolled against 11.3.x