GoogleCloudPlatform / appengine-symfony-starter-project

Symfony Starter Project on Google App Engine
Apache License 2.0
42 stars 13 forks source link

Twig Issues in Production #25

Open pdugas opened 6 years ago

pdugas commented 6 years ago

There appears to be something missing from the modified Twig\Environment object. When the csrf_token() function is used in a template, I'm getting an error from the baseclass' getRuntime() method indicating it was unable to load Symfony\Bridge\Twig\Form\TwigRenderer. I worked around it by passing the token in from the controller instead of using the function in the template. I tried digging in to see what I could figure out but I'm not following what's going on in that class so I'm not really able to provide any insight into the root cause. Sorry.

pdugas commented 6 years ago

Getting the same issue with app.user which appears to be null but if I pass in $this->getUser() from the controller and use that instead of app.user, things work as expected. Something's hosed with Twig in this setup still.

pdugas commented 6 years ago

And another... Trying to add EasyAdminBundle. Had to patch around Doctrine's FileCache failing if the cache folder isn't writeable even though it's not trying to write to it javiereguiluz/EasyAdminBundle#1954 then ran into what I'm guessing is this Twig issue again.

request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Could not parse property path "[entities][]". Unexpected token "[" at position 10")." at /base/data/home/apps/p~xxx/staging.xxx/vendor/javiereguiluz/easyadmin-bundle/src/Resources/views/default/list.html.twig line 1 {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\"Could not parse property path \"[entities][]\". Unexpected token \"[\" at position 10\"). at /base/data/home/apps/p~xxx/staging.xxx/vendor/javiereguiluz/easyadmin-bundle/src/Resources/views/default/list.html.twig:1, Symfony\\Component\\PropertyAccess\\Exception\\InvalidPropertyPathException(code: 0): Could not parse property path \"[entities][]\". Unexpected token \"[\" at position 10 at /base/data/home/apps/p~xxx/staging.xxx/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyPath.php:116)"} []
pdugas commented 6 years ago

I've reached out to the Symfony folk here https://github.com/symfony/symfony/issues/25368

max4kaps commented 6 years ago

@pdugas , same here. I've changed :

twig: strict_variables: true

To:

twig: strict_variables: false

and it fixes the issue.

Hope the solution will be found soon...