Jump to content

Got error 'PHP message: PHP Deprecated: Using php-function "implode" as a modifier


Butch0071

Recommended Posts

Presta: 8.0.4

PHP ver 8.0.30

I got that error in logs:

Got error 'PHP message: PHP Deprecated: Using php-function "implode" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in /httpdocs/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php on line 114

Would appreciate any tips. Thank you

 

 

Link to comment
Share on other sites

  • 4 weeks later...
On 3/4/2024 at 3:27 PM, Butch0071 said:

Presta: 8.0.4

PHP ver 8.0.30

I got that error in logs:

Got error 'PHP message: PHP Deprecated: Using php-function "implode" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in /httpdocs/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php on line 114

Would appreciate any tips. Thank you

 

 

It isn't an error, just a warning and it won't affect the working of your store. You can also get these where themes use other php functions such as in_array. Basically the smarty project is removing all the php function wrappers from their code and this is advanced notice that this will happen.

If it *really* bothers you, then you can create a smarty modifier plugin as a wrapper, although you'll need to give the modifier a slightly different name and then search and replace them in your theme template files. For example for the php function is_array you can create a new modifier called isarray e.g. create the file <yourtheme>/plugins/modifier.isarray.php:

 

<?php
/**
 * Smarty plugin
 *
 * @package    Smarty
 * @subpackage PluginsModifier
 */
/**
 * Smarty is_array php wrapper modifier plugin
 * Type:     modifier
 * Name:     isarray
 * Purpose:  check whether input is an array or not and stop those pesky deprecation warnings
 * Input:
 *          - Object|array: array or object to count
 *
 * @param mixed $$mixedInput  input array/object
 *
 * @return bool
 */
function smarty_modifier_isarray($mixedInput)
{
    /*
     * @see https://www.php.net/is_array
     * Returns true if value is an array, false otherwise.
     */

    return is_array($mixedInput);
}

You would then search your theme and look for "is_array" e.g. a line like this:

{if $product.customizations|is_array && $product.customizations|count}

And you need to change it to the new modifier name which is:

{if $product.customizations|isarray && $product.customizations|count}

Then the warnings will stop (for that particular php function). Just need to repeat the process for any others, creating a modifier as appropriate.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...