Fix exception where node isn't callable#1414
Closed
MacilPrime wants to merge 1 commit intotwigphp:masterfrom
Closed
Fix exception where node isn't callable#1414MacilPrime wants to merge 1 commit intotwigphp:masterfrom
MacilPrime wants to merge 1 commit intotwigphp:masterfrom
Conversation
Twig_Node::getAttribute throws an exception if the node doesn't have the given attribute. Call.php has code to deal with the node having a falsy 'callable' attribute, but doesn't handle the case where the node doesn't have a callable attribute.
Contributor
|
Can you reproduce this error with a simple Twig template? Being able to reproduce it would help a lot in fixing the issue the right way. |
Contributor
|
I've tried to reproduce the error with no luck so far (the i18n extension works fine for me in version 1.0.1 and Twig master). But anyway, I've made the code more robust in 23efa7b, so you won't have the issue anymore. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've been trying to upgrade my Tinyboard fork's version of Twig to 1.15.1 from a several years old version. Tinyboard uses the Twig I18n extension (I updated the Extensions folder to Twig-extensions v1.0.1), and an extension of its own that just adds some simple filters. I started getting this exception on most pages after updating Twig:
I think this issue in another project is related: kolber/stacey#91
I notice that Twig_Node_Expression_Function only sometimes sets the 'callable' attribute on itself. Call.php appears to have logic for handling the callable attribute not being set, but it forgets to actually catch the exception if it's not set. I added a try-catch block, and things seem to be all working now. I'm not familiar with the Twig codebase, so someone else will have to judge the correctness of this.