-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Acessing globally imported macro in another macro fails with PHP fatal error #1052
Labels
Comments
Merged
fabpot
added a commit
that referenced
this issue
Aug 3, 2013
This PR was merged into the master branch. Discussion ---------- Improved macros | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #861, #867, #929, #1052 | License | MIT | Doc | yes * Fixed fatal error for unknown macro * Added support for named arguments for macros * Added support for directly call macros defined in the same template Commits ------- 3004ba1 Added support for directly call macros defined in the same template 63615a6 Added support for named arguments for macros 09fedb8 Fixed fatal error for unknown macro 9e96837 Refactored parsing of macros
Please reopen this issue due to 74586e9 |
hason
added a commit
to hason/Twig
that referenced
this issue
Jan 2, 2014
hason
added a commit
to hason/Twig
that referenced
this issue
Jul 8, 2014
hason
added a commit
to hason/Twig
that referenced
this issue
Jul 14, 2014
@fabpot the parser should be taught that the body of a macro tag is always isolated in scope, and so should have its own set of imported symbols, due to the way macros are implemented currently |
fabpot
added a commit
that referenced
this issue
May 17, 2019
…ble in macros without re-importing them (fabpot) This PR was merged into the 2.x branch. Discussion ---------- Macros imported "globally" in a template are now available in macros without re-importing them closes #1790, closes #1052, closes #2414, closes #2442 Commits ------- e138164 macros imported "globally" in a template are now available in macros without re-importing them
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Twig 1.12.3 (2013-04-08)
Assume we have this template:
The docs say, that macros have no access to global scope. That's fine. But they still track imported macroses!
Line
{{ unknown_variable.moody }}
runs without errors producing an empty strings (with strict variables disabled)The other line
{{ clm.moody }}
fails with fatal error Call to a member function getmoody() on a non-objectAs far as I could dig into the sources, I found that in ExperssionParser.php:368 uses
$this->parser->getImportedSymbol
to look forclm
variable, that usesParser::importedSymbols
which is global. Butclm
isn't included in the$context
of the generated template method. Andstrict_variables
don't help here.And in generated template method we have
echo $_clm_->moody();
(and$_clm_
isnull
since it doesn't exists in$context
) with no sanity checks.Solutions:
The text was updated successfully, but these errors were encountered: