Installed this module today and immediately ran into this bug (D9.5.4, PHP8.1). Thank you for patch #3! Great module, very easy to use.
- Status changed to Needs work
over 1 year ago 10:28am 4 March 2023 - π¨π¦Canada mandclu
The change in question was introduced for the sake of Drupal 10 compatibility, specifically the newer version of Twig used. With the patch applied, Upgrade Status once again highlights three problems for this module:
Using an "if" condition on "for" tag in "modules/custom/layout_builder_tabs/templates/tabs.html.twig" at line 18 is deprecated since Twig 2.10.0, use a "filter" filter or an "if" condition inside the "for" body instead (if your condition depends on a variable updated inside the loop). See https://drupal.org/node/3071078.
It's definitely regrettable that the changes have created an issue for Drupal 9.x sites, but we need to find a solution that doesn't break Drupal 10 compatibility. I'll experiment with the solution originally suggest in #3308336: Twig\Error\RuntimeError: The callable passed to the "filter" filter must be a Closure in sandbox mode β which is slightly different, to see if that might fix the issue while maintaining compatibility with the most recent versions of Drupal.
- Status changed to Needs review
over 1 year ago 11:31am 4 March 2023 - π¨π¦Canada mandclu
Here's an updated patch that should avoid Twig errors in Drupal 9 and 10.
Using the patch above, when you add an empty Tab section, this is what you get
Twig\Error\RuntimeError: The "filter" filter expects an array or "Traversable", got "NULL". in twig_array_filter() (line 18 of modules/contrib/layout_builder_tabs/templates/tabs.html.twig).But for tab section with content, it works well.
- πΊπΈUnited States guymandude
The #11 patch is not working for my D10 site. It has also rendered Layout Builder for that content type even after uninstalling both Layout Builder and Layout Builder Tabs and reinstalling Layout Builder.
Prior to patch, got this error when clicking Manage Layout:
Warning: Undefined array key "block_id" in __TwigTemplate_4a3fe46f3c0ba04dfda5c592bf4b89f1->doDisplay() (line 173 of sites/default/files/php/twig/6460750b6f7e8_tabs.html.twig_5sroUazadlcoTpU0Pqk4ZMapg/hfLTqiiT0Z2P2C3pwfsvkun2lluC9YVZyTgo32fTQp8.php).
After patch, got this error when clicking Manage Layout:
The website encountered an unexpected error. Please try again later.
Twig\Error\RuntimeError: The callable passed to the "filter" filter must be a Closure in sandbox mode. in twig_check_arrow_in_sandbox() (line 41 of modules/layout_builder_tabs/templates/tabs.html.twig).
Patch #11 works fine for me on a clean 10.1.3 site. The cache needs to be cleared though before the error disappears. I'm also getting the error mentioned in #13 if I add an empty tab section, so one should add blocks to it straight away before saving the layout. I suppose an extra check is needed to test wether any blocks are present.
- πͺπΈSpain pgrandeg
I agree with @GuyManDude this patch solves the problem only partially.
The #11 patch works good while creating nodes, but it is crashing when you use an empty (no blocks inside) 'Tabs' region in a view mode configuration with Layout Builder.Steps to recreate:
Create a CT
Go to Manage display use default or enable 'full'
Enable to use Layout Builder and to use LB in nodes
Configure 'default' or 'full' layout
Include a new 'Tabs' section to the layout with no content, no blocks inside
Create a new node of that CT, then you will see the error Twig\Error\RuntimeError: The callable passed to the "filter" filter must be a Closure in sandbox mode. in twig_check_arrow_in_sandbox() (line 41 of modules/layout_builder_tabs/templates/tabs.html.twig).I have prepared a patch to set the 'tabs' $build index when it is not setted, and it works perfect in my environment.
I hope it helps
- πͺπΈSpain joe_carvajal Seville (Spain)
#17 seems to be working fine in D10. Thank you!
- π―π²Jamaica axle_foley00
I had this issue as well and the patch in #17 worked for me.
- Merge request !4Issue #3305095 by pgrandeg: Twig\Error\RuntimeError: The callable passed to... β (Open) created by pgrandeg
- Status changed to RTBC
9 months ago 11:39pm 12 February 2024 - Status changed to Fixed
7 months ago 3:21pm 13 April 2024 - π¨π¦Canada mandclu
Thanks for everyone's work on this issue. This fix has been committed, and will be included in a new, D11-ready release soon.
-
mandclu β
committed f228b48b on 1.0.x
Issue #3305095 by pgrandeg, joe_carvajal, mandclu: Twig\Error\...
-
mandclu β
committed f228b48b on 1.0.x
Automatically closed - issue fixed for 2 weeks with no activity.