Need to upgrade Smarty from 4.1 to 4.3 for compatibility with PHP 8.2 #1614

Closed
opened 2026-10-05 00:50:18 +02:00 by adam · 5 comments
Owner

Using Piwigo with PHP 8.2 gives lots of deprecation notices in the smarty library.

Deprecated:  Creation of dynamic property Smarty_Internal_Extension_Handler::$registerPlugin is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182
Deprecated:  Creation of dynamic property Smarty_Internal_Extension_Handler::$registerFilter is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182
Deprecated:  Creation of dynamic property Smarty_Internal_Extension_Handler::$append is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182
Deprecated:  Creation of dynamic property Smarty_Internal_Extension_Handler::$getTemplateVars is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182
Warning:  Cannot modify header information - headers already sent by (output started at …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php:182) in …/include/page_header.php on line 99
Deprecated:  Creation of dynamic property Smarty_Internal_Extension_Handler::$unregisterFilter is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182
Deprecated:  Creation of dynamic property Smarty_Internal_Template::$compiled is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_template.php on line 719

I see that Piwigo is using version 4.1 of Smarty. According to the changelog, compatibility with PHP 8.2 was introduced with version 4.3

Alternatively, just ignore deprecations by changing this line.

https://github.com/Piwigo/Piwigo/blob/4729504aac02545e9d5e27717cbf7f9ce3663b9d/include/config_default.inc.php#L501

In general, you would want to see deprecations in test/development, but not in live environments.

Using Piwigo with PHP 8.2 gives lots of deprecation notices in the smarty library. ``` Deprecated: Creation of dynamic property Smarty_Internal_Extension_Handler::$registerPlugin is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182 Deprecated: Creation of dynamic property Smarty_Internal_Extension_Handler::$registerFilter is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182 Deprecated: Creation of dynamic property Smarty_Internal_Extension_Handler::$append is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182 Deprecated: Creation of dynamic property Smarty_Internal_Extension_Handler::$getTemplateVars is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182 Warning: Cannot modify header information - headers already sent by (output started at …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php:182) in …/include/page_header.php on line 99 Deprecated: Creation of dynamic property Smarty_Internal_Extension_Handler::$unregisterFilter is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 182 Deprecated: Creation of dynamic property Smarty_Internal_Template::$compiled is deprecated in …/include/smarty/libs/sysplugins/smarty_internal_template.php on line 719 ``` I see that Piwigo is using version 4.1 of Smarty. According to the [ changelog](https://github.com/smarty-php/smarty/blob/master/CHANGELOG.md), compatibility with PHP 8.2 was introduced with version 4.3 Alternatively, just ignore deprecations by changing this line. https://github.com/Piwigo/Piwigo/blob/4729504aac02545e9d5e27717cbf7f9ce3663b9d/include/config_default.inc.php#L501 In general, you would want to see deprecations in test/development, but not in live environments. <!-- github-sync-id:1518876926 -->
adam closed this issue 2026-10-05 00:50:19 +02:00
Author
Owner

I made a first try to update Smarty to version 4.3.1 and I get a lot of these warnings :

Deprecated: Using php-function "sprintf" as a modifier is deprecated and will be removed in a future release. [...]
Deprecated: Using php-function "urlencode" as a modifier is deprecated and will be removed in a future release. [...]
Deprecated: Using php-function "intval" as a modifier is deprecated and will be removed in a future release. [...]

It's going to be a complicated update...

I made a first try to update Smarty to version 4.3.1 and I get a lot of these warnings : > Deprecated: Using php-function "sprintf" as a modifier is deprecated and will be removed in a future release. [...] > Deprecated: Using php-function "urlencode" as a modifier is deprecated and will be removed in a future release. [...] > Deprecated: Using php-function "intval" as a modifier is deprecated and will be removed in a future release. [...] It's going to be a complicated update... <!-- github-comment-id:1508918524 -->
Author
Owner

Hi
ok for sprintf
try in include/template.class.php add line 114
$this->smarty->registerPlugin('modifier', 'sprintf', 'sprintf');
try add line 115 for urlenconde
$this->smarty->registerPlugin('modifier', 'urlencode', 'urlencode');
try add line 116 for intval
$this->smarty->registerPlugin('modifier', 'intval', 'intval');
if that's a solution

Hi ok for sprintf try in include/template.class.php add line 114 `$this->smarty->registerPlugin('modifier', 'sprintf', 'sprintf');` try add line 115 for urlenconde `$this->smarty->registerPlugin('modifier', 'urlencode', 'urlencode');` try add line 116 for intval `$this->smarty->registerPlugin('modifier', 'intval', 'intval');` if that's a solution <!-- github-comment-id:1510092613 -->
Author
Owner

Much better with all these

    $this->smarty->registerPlugin('modifier', 'sprintf', 'sprintf');
    $this->smarty->registerPlugin('modifier', 'urlencode', 'urlencode');
    $this->smarty->registerPlugin('modifier', 'intval', 'intval');
    $this->smarty->registerPlugin('modifier', 'file_exists', 'file_exists');
    $this->smarty->registerPlugin('modifier', 'constant', 'constant');
    $this->smarty->registerPlugin('modifier', 'json_encode', 'json_encode');
    $this->smarty->registerPlugin('modifier', 'htmlspecialchars', 'htmlspecialchars');
    $this->smarty->registerPlugin('modifier', 'implode', 'implode');
    $this->smarty->registerPlugin('modifier', 'stripslashes', 'stripslashes');
    $this->smarty->registerPlugin('modifier', 'in_array', 'in_array');
Much better with all these ``` $this->smarty->registerPlugin('modifier', 'sprintf', 'sprintf'); $this->smarty->registerPlugin('modifier', 'urlencode', 'urlencode'); $this->smarty->registerPlugin('modifier', 'intval', 'intval'); $this->smarty->registerPlugin('modifier', 'file_exists', 'file_exists'); $this->smarty->registerPlugin('modifier', 'constant', 'constant'); $this->smarty->registerPlugin('modifier', 'json_encode', 'json_encode'); $this->smarty->registerPlugin('modifier', 'htmlspecialchars', 'htmlspecialchars'); $this->smarty->registerPlugin('modifier', 'implode', 'implode'); $this->smarty->registerPlugin('modifier', 'stripslashes', 'stripslashes'); $this->smarty->registerPlugin('modifier', 'in_array', 'in_array'); ``` <!-- github-comment-id:1510418167 -->
Author
Owner

Ok with that in addition
$this->smarty->registerPlugin('modifier', 'ucfirst', 'ucfirst');

Ok with that in addition `$this->smarty->registerPlugin('modifier', 'ucfirst', 'ucfirst');` <!-- github-comment-id:1510507737 -->
Author
Owner

FYI, new Debian stable (12) is only with php8.2.

FYI, new Debian stable (12) is only with php8.2. <!-- github-comment-id:1590526804 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1614