smarty-php / smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
Other
2.23k stars 703 forks source link

"Too many shorthand attributes" error message after migrated to smarty 5 #949

Closed rodriguezny closed 4 months ago

rodriguezny commented 4 months ago

After migrated our project(Tiki Wiki CMS Groupware => https://tiki.org/HomePage to smarty 5, I have the following error thrown in the template https://gitlab.com/tikiwiki/tiki/-/blob/master/templates/examples/search/related_tracker_items.tpl on line 5.

Error: Syntax error in template "file:examples/search/related_tracker_items.tpl" on line 5 "{if preg_match_all('/(.+?)\:([^\v]+)$/mis', $relationValue, $matches, 2)}" too many shorthand attributes

Any idea of the mistake in my code ? I explored some issues reported in previous years about the same error message "too many shorthand attribute" but none of them helped me, they are not similar to mine expect that they are both related to the use of the {if}{/if} block.

Below is the entire content of my template

image
wisskid commented 4 months ago

The problem is caused by this call having 4 parameters... Somewhere while refactoring, I set protected $shorttag_order = ['var1', 'var2', 'var3']; to temporarily fix a bunch of problems, but I forgot to fix this properly. This went undetected as all unit tests use less than 4 parameters for function calls. This definitely needs a fix.

Also, Smarty5 does not seem to support passing parameters by reference anymore, as this code fragment does (the $matches parameter).

wisskid commented 4 months ago

@rodriguezny https://github.com/smarty-php/smarty/pull/953 should have fixed the 'too many shorthand attributes' error. Can you verify against smarty dev-master?

rodriguezny commented 4 months ago

Ok, let me verify against smarty dev-master. Thanks!

rodriguezny commented 4 months ago

Thanks @wisskid for the fix, I installed smarty dev-master, it works fine, the issue no longer exists.