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

getTemplateVars not working for in template defined variables #991

Open
blaaat opened this issue Apr 11, 2024 · 3 comments
Open

getTemplateVars not working for in template defined variables #991

blaaat opened this issue Apr 11, 2024 · 3 comments

Comments

@blaaat
Copy link

blaaat commented Apr 11, 2024

Hi,

In Smarty 4 it was possible to assign a variable inside a template and use this after fetching in code.

{assign var="var" value=$from_name scope="root"}

$smarty->getTemplateVars()

In smarty 5.0.2 this only returns the variables assigned in PHP. Tried to change the (undocumented) scope to global without success

@wisskid
Copy link
Contributor

wisskid commented Apr 12, 2024

I can make this work, but only when using the 'global' scope:

{assign var="b" value="x" scope="global"}
$smarty->getTemplateVars('b') // = 'x'

@blaaat
Copy link
Author

blaaat commented Apr 12, 2024

You're right, I must have made a mistake when testing this yesterday. Thanks :)

So this issue is mostly related to #878
Maybe it would be nice to have this backwards incompatible change documented in the changelog.

@wisskid
Copy link
Contributor

wisskid commented Apr 12, 2024

You are right. The change was documented in the changelog as "Template variable scope bubbling has been simplified and made more consistent. The global scope now equals the Smarty scope in order to avoid global state side effects. Please read the documentation for more details." This doesn't really suggest what could go wrong, but I hadn't forseen this either to be honest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants