Re: [Tiki-devel] Using php-function "strstr" as a modifier is deprecated
Jonny Bradley via TikiWiki-devel <[email protected]> Thu, 10 Aug 2023 10:53:32 +0100
| Newsgroups | gmane.comp.cms.tiki.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Bernard and all This is an important topic for some of us i think, anyone who uses smarty templates a lot to customise an application, usually with plugin list, will probably have worked out how to add php functions as modifiers in a tiki.ini file using the smarty_security_modifiers array (and before that using the pref on the security control panel). Thanks for the link to the issue discussion on GitHub, from what i can see this is to avoid type casting errors in php 8+ which are now fatal and before just emitted warnings, and because a modifier can't check that the thing it's modifying is really a string (for instance) and without a wrapper around the php function todo this (in a registered custom modifier) your page will break. So what should we do? For one i guess we have to remove the defaults in lib/init/smarty.php:77 and all the uses of them in tiki. And for our custom templates i'm guessing we have to change these modifiers to be functions (which actually i started doing a while ago as it seemed to make sense, as they are functions ;) I guess adding some more modifiers to lib/smarty_tiki like `str_contains` and maybe `str_starts_with` and `str_ends_with` etc might help, also `in_array`, `array_filter` etc i use quite often... But does anyone else have any better suggestions? jonny > On 3 Aug 2023, at 22:00, Bernard Sfez via TikiWiki-devel <[email protected]> wrote: > > Hello, > > Some of us uses php-function inside Smarty template but since Tiki25 and Tiki26 (Smarty4 and PHP8) this method has been deprecated. > > DEPRECATED: Using php-function "strstr" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. > > I thought it was trivial and already solved somewhere, but I understood that it isn’t. (https://github.com/smarty-php/smarty/issues/813) > > So for my own Tiki I created lib/smarty_tiki/modifier.contains.php using “str_contains” function as explained here: https://www.php.net/manual/en/function.str-contains.php > However, I couldn’t find a real guide on how to create a marty_tiki modifier (I open several others) and may be we need a generic solution for this function (JonnyB) and others may have already started something. > > Any thought on how we can organise a smart way in Tiki with this ? > > Bernard > _______________________________________________ > TikiWiki-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel _______________________________________________ TikiWiki-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel