Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register commonly used deprecated modifiers to Smarty config #33136

Merged
merged 1 commit into from Jul 19, 2023

Conversation

kpodemski
Copy link
Contributor

Questions Answers
Branch? 8.1.x
Description? I discovered that many Smarty modifiers were not available and threw deprecate warnings after the recent Smarty upgrade.
Type? bug fix
Category? CO
BC breaks? no
Deprecations? no
How to test? Autotests and CI should be enough, to me, the best way to see before and after, was to see the modules translations page and theme translations page with debug mode enabled
Fixed ticket? Fixes #32703
Related PRs n/a
Sponsor company Acme Company

@kpodemski kpodemski requested a review from a team as a code owner July 7, 2023 06:56
@prestonBot prestonBot added 8.1.x Branch Bug fix Type: Bug fix labels Jul 7, 2023
Copy link
Contributor

@ga-devfront ga-devfront left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THANKS ! Not much to add the code speaks for itself.

@ps-jarvis ps-jarvis added the Waiting for QA Status: action required, waiting for test feedback label Jul 7, 2023
@kpodemski kpodemski added the Waiting for dev Status: action required, waiting for tech feedback label Jul 7, 2023
@kpodemski
Copy link
Contributor Author

cc @matks

Copy link
Contributor

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kpodemski

@kpodemski kpodemski added this to the 8.1.1 milestone Jul 10, 2023
@Hlavtox
Copy link
Contributor

Hlavtox commented Jul 19, 2023

Before, when visiting password reset page.

[19-Jul-2023 11:15:06 Europe/Prague] 
PHP Deprecated:  Using php-function "stripslashes" as a modifier is deprecated and will be removed in a future release. 
Use Smarty::registerPlugin to explicitly register a custom modifier. 
in C:\xampp\htdocs\81x\vendor\smarty\smarty\libs\sysplugins\smarty_internal_compile_private_modifier.php on line 114

After change, no errors. ✅

@Hlavtox Hlavtox added QA ✔️ Status: check done, code approved and removed Waiting for QA Status: action required, waiting for test feedback labels Jul 19, 2023
@Hlavtox Hlavtox merged commit 85f8802 into PrestaShop:8.1.x Jul 19, 2023
38 checks passed
@kpodemski kpodemski removed the Waiting for dev Status: action required, waiting for tech feedback label Jul 24, 2023
@SharakPL
Copy link
Contributor

SharakPL commented Aug 3, 2023

Looks like there are duplications in this file eg. floatval, intval, json_encode, mt_rand, trim...

smartyRegisterFunction($smarty, 'modifier', 'floatval', 'floatval');
smartyRegisterFunction($smarty, 'modifier', 'htmlentities', 'htmlentities');
smartyRegisterFunction($smarty, 'modifier', 'intval', 'intval');
smartyRegisterFunction($smarty, 'modifier', 'json_decode', 'json_decode');
smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode');
smartyRegisterFunction($smarty, 'modifier', 'mt_rand','mt_rand');
smartyRegisterFunction($smarty, 'modifier', 'rand','rand');
smartyRegisterFunction($smarty, 'modifier', 'strtolower','strtolower');
smartyRegisterFunction($smarty, 'modifier', 'str_replace','str_replace');
smartyRegisterFunction($smarty, 'modifier', 'strval','strval');
smartyRegisterFunction($smarty, 'modifier', 'trim', 'trim');

smartyRegisterFunction($smarty, 'modifier', 'intval', 'intval');
smartyRegisterFunction($smarty, 'modifier', 'date', 'date');
smartyRegisterFunction($smarty, 'modifier', 'trim', 'trim');
smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode');
smartyRegisterFunction($smarty, 'modifier', 'in_array', 'in_array');
smartyRegisterFunction($smarty, 'modifier', 'stripslashes', 'stripslashes');
smartyRegisterFunction($smarty, 'modifier', 'mt_rand', 'mt_rand');
smartyRegisterFunction($smarty, 'modifier', 'md5', 'md5');
smartyRegisterFunction($smarty, 'modifier', 'floatval', 'floatval');

Am I missing something or it does need a cleanup?

@neocol83
Copy link

neocol83 commented Aug 8, 2023

// Native PHP Functions
smartyRegisterFunction($smarty, 'modifier', 'addcslashes', 'addcslashes');
smartyRegisterFunction($smarty, 'modifier', 'addslashes', 'addslashes');
smartyRegisterFunction($smarty, 'modifier', 'date','date');
smartyRegisterFunction($smarty, 'modifier', 'end', 'smarty_endWithoutReference');
smartyRegisterFunction($smarty, 'modifier', 'floatval', 'floatval');
smartyRegisterFunction($smarty, 'modifier', 'htmlentities', 'htmlentities');
smartyRegisterFunction($smarty, 'modifier', 'intval', 'intval');
smartyRegisterFunction($smarty, 'modifier', 'json_decode', 'json_decode');
smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode');
smartyRegisterFunction($smarty, 'modifier', 'mt_rand','mt_rand');
smartyRegisterFunction($smarty, 'modifier', 'rand','rand');
smartyRegisterFunction($smarty, 'modifier', 'strtolower','strtolower');
smartyRegisterFunction($smarty, 'modifier', 'str_replace','str_replace');
smartyRegisterFunction($smarty, 'modifier', 'strval','strval');
smartyRegisterFunction($smarty, 'modifier', 'trim', 'trim');
smartyRegisterFunction($smarty, 'modifier', 'ucfirst', 'ucfirst');
smartyRegisterFunction($smarty, 'modifier', 'urlencode','urlencode');
smartyRegisterFunction($smarty, 'modifier', 'htmlspecialchars','htmlspecialchars');
smartyRegisterFunction($smarty, 'modifier', 'implode', 'implode');
smartyRegisterFunction($smarty, 'modifier', 'explode', 'explode');
smartyRegisterFunction($smarty, 'modifier', 'print_r', 'print_r');
smartyRegisterFunction($smarty, 'modifier', 'var_dump', 'var_dump');
smartyRegisterFunction($smarty, 'modifier', 'lcfirst', 'lcfirst');
smartyRegisterFunction($smarty, 'modifier', 'nl2br', 'nl2br');
smartyRegisterFunction($smarty, 'modifier', 'sizeof', 'sizeof');
smartyRegisterFunction($smarty, 'modifier', 'in_array', 'in_array');
smartyRegisterFunction($smarty, 'modifier', 'substr', 'substr');
smartyRegisterFunction($smarty, 'modifier', 'stripslashes', 'stripslashes');
smartyRegisterFunction($smarty, 'modifier', 'md5', 'md5');
smartyRegisterFunction($smarty, 'modifier', 'strtoupper', 'strtoupper');

I think maybe like that works

@ivordurham
Copy link

I encountered this problem today with array_merge in PrestaShop 8.1.3/PHP 8.1.25 when I first logged in to admin after a brand new install.

[SHOPPATH]/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php
[16384] Using php-function "array_merge" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier.

@kpodemski
Copy link
Contributor Author

It's true we don't have array_merge in https://github.com/PrestaShop/PrestaShop/blob/develop/config/smarty.config.inc.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.1.x Branch Bug fix Type: Bug fix QA ✔️ Status: check done, code approved
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

10 participants