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

Deprecated: Using unregistered function in a template is deprecated #965

Closed olelis closed 4 months ago

olelis commented 4 months ago

Starting from 4.5.1, you have to register all functions that are used in the template. This includes both system and userland functions.

If you fail to do so, then you will get following error message ( ! ) Deprecated: Using unregistered function "getInteger" in a template is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier.

In this case, the function was used in the following way: <strong>{getInteger($totals.totalorders)}</strong>

In our codebase, we will have like 50-70 different functions that will need to be registered on each page load. Not all of them will be used on each page, but it will be quite a lot of work to actually specify all used functions for each template. Yes, some of them are used as modifiers, like the code above, while some are used to get information, for example current domain or username.

However, I don't understand, what is the reasoning for such drastic requirement that each function must be registered? Do you have PR with discussion or why it is decided as a requirement to do so ?

Just trying to understand the logic for such big change that will require quite a lot of work on our end.

wisskid commented 4 months ago

@olelis much debate has been ongoing on this topic. I can imagine it is not easy to find it, therefore I've created a Discussion page on this topic. I hope this answers your questions.