Re: [Tiki-devel] Using php-function "strstr" as a modifier is deprecated
Bernard Sfez via TikiWiki-devel <[email protected]> Sun, 13 Aug 2023 14:30:48 +0300
| Newsgroups | gmane.comp.cms.tiki.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
> TikiLib::lib('smarty')->registerPlugin('strstr');
>
> added to _custom/lib/setup/custom.php enough for now?
I’m sure that it make sense to you guys, but not for everyone.
(and I tried to create a file with the code you suggested on a Tiki26) 😇
However, adding to "_custom/lib/setup/custom.php” my contains modifier code worked like a charm so I guess I’m missing a little something.
Anymore 2 cents about this ?
Bernard
> On 10 Aug 2023, at 18:05, Victor Emanouilov via TikiWiki-devel <[email protected]> wrote:
>
> Hi Jonny, Bernard,
>
> Isn't code like:
>
> TikiLib::lib('smarty')->registerPlugin('strstr');
>
> added to _custom/lib/setup/custom.php enough for now?
>
> I am pretty sure we will revamp this thing in smarty 5 and the upcoming directory structure revamp.
>
> I am also fine extending the default list of built-in php functions accessible to smarty lib/init/smarty.php but I think Benoit Grégoire had problems with this approach.
>
> Regards,
> Victor
>
> On 8/10/23 12:53 PM, Jonny Bradley via TikiWiki-devel wrote:
>> 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
>
>
> _______________________________________________
> 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