Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The following error is reported enabling the theme in latest D8-RC, making the theme unusable.
Twig_Sandbox_SecurityError: Calling "setOptions" method on a "Drupal\Core\Url" object is not allowed in "themes/bear_skin/templates/html.html.twig" at line 28. in Drupal\Core\Template\TwigSandboxPolicy->checkMethodAllowed() (line 101 of /web/htdocs/www.taoartconsulting.com/home/core/lib/Drupal/Core/Template/TwigSandboxP...).
Comments
Comment #2
darol100 CreditAttribution: darol100 as a volunteer and commentedI'm porting light_skeleton and I ran into this problem when I try to use RC4. I started the development on RC2 and it was working fine.
In my case it was due to this line -
{{ link(item.title, item.url.setOptions({'set_active_class' : TRUE, 'attributes' : {'class' : 'navbar-link'}})) }}
. I have not been able to figure out how to fixed it, but I open a question in Drupal Stack Exchange - http://drupal.stackexchange.com/questions/180919/twig-sandbox-securityer...Fixing this issue is going to benefit both projects. I will keep you update if I figure out the problem on my light_skeleton project.
Comment #3
darol100 CreditAttribution: darol100 as a volunteer and commentedHere is some extra information
The actual problem is on menu--main.html.twig, where the theme is using multiples "setOptions" and this is why is giving you the WSOD and the security error. We need to find a way to achieve this without using "setOptions", we might be able to do it with a "if" statement, but it some hacky to me.
I think we should investigate if there is a better way to do this in Twig (i think).
Comment #4
alioso CreditAttribution: alioso commentedHey daeol100, thanks for reporting. Yeah, I had developed with rc2 when that was not a problem. What I ended up doing is a complete rewrite for the twig template. It was actually rather ugly, so this will work much better: https://github.com/zivtech/bear_skin/blob/3adfe45dfe4d9f49724fc609ef88a1...
Release in the latest 8.x-1.4
Comment #5
darol100 CreditAttribution: darol100 as a volunteer and commented@alioso, I will take a look at your changes, and review your changes in couple days.
Feel free to try on fix on the same issue on Light Skeleton #2617288: Light Skeleton - Twig_Sandbox_SecurityError .
Comment #6
alioso CreditAttribution: alioso commented