Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with the guard tag #4505

Closed
javiereguiluz opened this issue Dec 17, 2024 · 2 comments · Fixed by #4511
Closed

Issue with the guard tag #4505

javiereguiluz opened this issue Dec 17, 2024 · 2 comments · Fixed by #4511

Comments

@javiereguiluz
Copy link
Contributor

I updated a bundle to start using the new guard tag: EasyCorp/EasyAdminBundle#6656

However, instead of the expected guard behavior, in tests you can now see a lot of messages like:

"Did you forget to run "composer require symfony/web-link"?
Unknown function "preload" in "@EasyAdmin/includes/_css_assets.html.twig"."
at UndefinedCallableHandler.php line 105

As @stof explained on Symfony Slack, this only happens when using Twig inside a Symfony application, where this class exists --> https://github.com/symfony/symfony/blob/7.3/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php

@stof proposed to either change the implementation of guard in Twig to skip the undefined callback handler when checking for function existence ... or provide a way for such handlers to opt-in for such bypass.

Thanks!

@fabpot
Copy link
Contributor

fabpot commented Dec 19, 2024

We cannot bypass undefined handlers as they might register functions/filters.
The problem here comes from Symfony implementation of such undefined handlers as Symfony throws an exception.
But Twig docs are very clear on this topic:

If the callable is not able to return a valid function/filter/tag, it must return false.

So, the only workaround I can see in Twig would be to catch all exceptions and ignore them.

@fabpot
Copy link
Contributor

fabpot commented Dec 19, 2024

See #4511

@fabpot fabpot closed this as completed in c1f7277 Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants