"Fixing" Deprecation Warning for Count function

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
postiffm
Forum Members
Forum Members
Posts: 128
Joined: Tue Nov 30, 2010 12:16 am

"Fixing" Deprecation Warning for Count function

Post by postiffm »

I have the following warning:
Deprecated: Using unregistered function "count" in a template is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in ... public_html/lib/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 651
By reading this forum, I understand that the warning is not an emergency and does not need to be "fixed" immediately, and that the dev team is considering options for all installations. As a smarty-dummy (please bear with me), I am asking this question for my learning: how would I "fix" this sort of thing now?

For example, I see in the template cssmenu the following:
<li class="{implode(' ',$liclass)}">
<a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if} href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}><span>{$node->menutext}</span></a>
Does the problem with count go away in smarty5 because count is now a built-in smarty function?

And, if implode or any other particular function is not built into smarty5, could register_function() be used to solve the problem?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1942
Joined: Mon Jan 29, 2007 4:47 pm

Re: "Fixing" Deprecation Warning for Count function

Post by Jo Morg »

As stated before, the warning is not an error, so no need for a fix. Whether count is going to be a built in modifier or not, is for the smarty team to decide. In any case registering EVERY PHP function with Smarty as a modifier and then maintaining it (even if we only select a few of the more popular or needed ones we are talking about a hundred or so functions) is exactly the reason why Smarty team decided to back away from that policy, and it may have a big memory foot print, and thus a significant impact in the site performance. Please follow our recommendations: just filter those notifications and everything will be fine.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
postiffm
Forum Members
Forum Members
Posts: 128
Joined: Tue Nov 30, 2010 12:16 am

Re: "Fixing" Deprecation Warning for Count function

Post by postiffm »

Thank you. Could you outline how to filter those notifications?

I thought I was safe to suggest count would be a built-in: https://smarty-php.github.io/smarty/sta ... ier-count/
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1942
Joined: Mon Jan 29, 2007 4:47 pm

Re: "Fixing" Deprecation Warning for Count function

Post by Jo Morg »

postiffm wrote: Fri May 24, 2024 3:35 pm Thank you. Could you outline how to filter those notifications?
https://www.slingacademy.com/article/ph ... s-notices/ under Configuring Error Reporting
postiffm wrote: Fri May 24, 2024 3:35 pm I thought I was safe to suggest count would be a built-in: https://smarty-php.github.io/smarty/sta ... ier-count/
Well, it has been an official modifier for ages, so yeah not a transitional addition. However the use of php callable as modifiers was a default behavior that precluded the need to register them in smarty, and that was the main change: https://github.com/smarty-php/smarty/issues/813. This affects a few of the core templates, but that is something that we'll address in due time. The worst side of it is that it may impact in the future most, if not all, of our users sites if we chose to follow suite from Smarty decision. As addressing on issue will mean addressing them all, whatever solution we come up with, it's not needed to go after all the modifiers in the core templates that may trigger the warning.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
postiffm
Forum Members
Forum Members
Posts: 128
Joined: Tue Nov 30, 2010 12:16 am

Re: [SOLVED] "Fixing" Deprecation Warning for Count function

Post by postiffm »

Thanks again, Jo. Please don't take my question/comments as a criticism. I understand the "situation" you all are in. I appreciate what you have done with CMSMadeSimple and I personally have learned a lot by using it to run our website.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1942
Joined: Mon Jan 29, 2007 4:47 pm

Re: "Fixing" Deprecation Warning for Count function

Post by Jo Morg »

postiffm wrote: Fri May 24, 2024 4:50 pm Please don't take my question/comments as a criticism
No worries, I didn't. 8)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Post Reply

Return to “CMSMS Core”