You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using WordPress and in there we attempt to load Twig templates.
For us we create a WP_CLI command, which registers itself before WordPress itself is loaded.
Previously (twig version v3.11.1 and before) this all worked great.
Twig allowed functions that were not defined yet to still be compiled as php files.
We did this using the same method as described in #3706.
See our repo of the CLI command.
But unfortunately now, since version v3.12.0, this does not work anymore and throws the following TypeError.
Uncaught TypeError: Failed to create closure from callable: function "_x" not found or invalid function name in /path/to/project/vendor/twig/twig/src/Util/ReflectionCallable.php:45
Now I have to confess i'm not having a full knowledge of the twig codebase yet.
But after searching and looking at the stacktraces, I've found that somewhere around these PR's to be where the problem started: #4206 or #4207
It seems like even if a function does not exist yet on compilation, it still attempts to extract it's attributes with the new CallableArgumentsExtractor.
Would there be a way to return the functionality to not validate those callable arguments if the function at that stage does not exist, therefore allowing the use of functions that are not yet defined on runtime?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
We're using WordPress and in there we attempt to load Twig templates.
For us we create a WP_CLI command, which registers itself before WordPress itself is loaded.
Previously (twig version v3.11.1 and before) this all worked great.
Twig allowed functions that were not defined yet to still be compiled as php files.
We did this using the same method as described in #3706.
See our repo of the CLI command.
But unfortunately now, since version v3.12.0, this does not work anymore and throws the following TypeError.
Now I have to confess i'm not having a full knowledge of the twig codebase yet.
But after searching and looking at the stacktraces, I've found that somewhere around these PR's to be where the problem started: #4206 or #4207
It seems like even if a function does not exist yet on compilation, it still attempts to extract it's attributes with the new CallableArgumentsExtractor.
Would there be a way to return the functionality to not validate those callable arguments if the function at that stage does not exist, therefore allowing the use of functions that are not yet defined on runtime?
Thanks in advance!
The text was updated successfully, but these errors were encountered: