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

Custom plugin invocation compiles into garbage #457

Closed
AnrDaemon opened this issue Jun 30, 2018 · 8 comments · Fixed by #573
Closed

Custom plugin invocation compiles into garbage #457

AnrDaemon opened this issue Jun 30, 2018 · 8 comments · Fixed by #573

Comments

@AnrDaemon
Copy link
Contributor

[01-Jul-2018 00:17:42 Europe/Moscow] PHP Parse error:  syntax error, unexpected '^' in …/tmp/smarty/templates/b06b264876f1056e83fb1c88d2b34b1f696d52d2_0.file.menu-sectionTree.smarty.cache.php on line 38

The relevant code is

    $tpl->registerPlugin('function', 'svgImage', [new SvgImage('/img/cat/icon'), 'render'], true, [
      'name', 'id', 'class', 'style', 'fallback'
    ]);

invoked as {svgImage name=$item.icon}, which somehow compiles into

echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['svgImage'][0], array( array('name'=>^#^.var_export($_smarty_tpl->tpl_vars[^#^item^#^]->value[^#^icon^#^],true).^#^),$_smarty_tpl ) );
@wisskid wisskid added the waiting Waiting for answer label Feb 19, 2020
@wisskid
Copy link
Contributor

wisskid commented Feb 19, 2020

Can't reproduce this, is this already fixed?

@AnrDaemon
Copy link
Contributor Author

I can reproduce it with 3.1.34. Will try to create a testcase.

@wisskid
Copy link
Contributor

wisskid commented Feb 20, 2020 via email

@AnrDaemon
Copy link
Contributor Author

AnrDaemon commented Feb 20, 2020

I wonder, how's that possible.
This is run under default system locale, which is configured as "en_US.UTF-8".

AnrDaemon added a commit to AnrDaemon/test-001 that referenced this issue Feb 20, 2020
AnrDaemon added a commit to AnrDaemon/test-001 that referenced this issue Feb 20, 2020
@AnrDaemon
Copy link
Contributor Author

@wisskid
Copy link
Contributor

wisskid commented Feb 20, 2020

The difference between my test and yours causing this bug is $smarty->setCaching(\Smarty::CACHING_LIFETIME_SAVED); (so not locale, indeed...)
I'll see if I can figure out what's going on here.

@wisskid wisskid added needs-fix and removed waiting Waiting for answer labels Feb 20, 2020
@wisskid
Copy link
Contributor

wisskid commented Feb 20, 2020

playground/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_registered_function.php:60

@wisskid
Copy link
Contributor

wisskid commented Feb 20, 2020

Okay, I figured this one out. You somehow found an impossible combination of parameters to $smarty->registerPlugin($type, $name, $callback, $cacheable = true, $cache_attr = null).

If you leave $cacheable true, as you did, then $cache_attr should be meaningless. $cache_attr is only interesting if $cacheable is false. So this should be easy to fix.

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

Successfully merging a pull request may close this issue.

2 participants