Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

PHP typing complaint

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
lsces
Smarty Rookie


Joined: 03 Dec 2011
Posts: 8

PostPosted: Sun Feb 07, 2016 1:07 pm    Post subject: PHP typing complaint Reply with quote

Having been using Smarty happily on PHP5.2 for many years, I've given in and as well as testing everything on PHP7 I'm tidying up the libraries and pulling in the latest versions. After a few problems I now have a working 'modern' setup, but with a few bugs.

Warning: preg_replace() expects parameter 4 to be integer, string given in /srv/website/externals/smarty/libs/plugins/modifier.regex_replace.php on line 36

The default for parameter 4 is -1, but when used in a cached template, a blank string is used. I've not tracked back to where it is generated, but with all the excessive nannying in PHP these days, little niggles like this are now the norm and while one could switch off warnings, THAT is the source of a much bigger can of worms as has resulted from changes since PHP5.2.

I've not worked out yet where the limit value would be populated in smarty, so switching the blank sting to -1 is probably a cleaner solution for now? That is if I could find where it's set Wink
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Sun Feb 07, 2016 1:50 pm    Post subject: Reply with quote

Can you show a source example (YOUR modifier call)?
Back to top
View user's profile Send private message
lsces
Smarty Rookie


Joined: 03 Dec 2011
Posts: 8

PostPosted: Sun Feb 07, 2016 4:04 pm    Post subject: Tracing through Reply with quote

OK .. now I've worked out how to track more of this, and the source is in the {pagination} module which includes

{assign var=pageUrlVar value=$smarty.capture.string|regex_replace:"/^\&/":""|regex_replace:'/"/':'%22':''}

I'm about half way through bringing the dvcs system up to date, but at present there are no changes to the .tpl files so it's in http://hg.lsces.org.uk/bw/bitweaver/themes/file/19138084b1fc/smartyplugins/function.pagination.php

Extra ... helps to include the template
http://hg.lsces.org.uk/bw/bitweaver/kernel/file/384778187d42/templates/pagination.tpl
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Mon Feb 22, 2016 11:13 am    Post subject: Reply with quote

Maybe you know regex operations are needed a lot of server power.

And you want only some string replacement so you should better use a string replacement function like

https://secure.php.net/manual/en/function.str-replace.php
Back to top
View user's profile Send private message
lsces
Smarty Rookie


Joined: 03 Dec 2011
Posts: 8

PostPosted: Mon Feb 22, 2016 11:40 am    Post subject: Reply with quote

elpmis wrote:
Maybe you know regex operations are needed a lot of server power.
And you want only some string replacement so you should better use a string replacement function like
https://secure.php.net/manual/en/function.str-replace.php

Yes rewriting the templates is a solution, but 'regex_replace' is a smarty function and has a problem when used with PHP7. That still needs fixing ...
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Mon Feb 22, 2016 11:44 am    Post subject: Reply with quote

In Smarty 3 you can use some PHP commands direcly inside templates. There's no longer need to use modificators Wink.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP