smarty
smarty copied to clipboard
PHP 8.2: Deprecation notices for dynamic properties
Upcoming PHP 8.2 throws even more deprecation notices for removal approach in PHP 9.
[ I solved my questions by asking... ]
Solution proposal will follow.
Improve for PHP 8.2 by using new AllowDynamicProperties flag only
------------ libs/sysplugins/smarty_internal_extension_handler.php ------------
@@ -36,6 +36,7 @@
* @property Smarty_Internal_Method_RegisterPlugin $registerPlugin
* @property mixed|\Smarty_Template_Cached configLoad
*/
+#[\AllowDynamicProperties]
class Smarty_Internal_Extension_Handler
{
public $objType = null;
----------------- libs/sysplugins/smarty_internal_template.php ----------------
@@ -24,6 +24,7 @@
*
* @method bool mustCompile()
*/
+#[\AllowDynamicProperties]
class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
{
/**
--------------------- libs/sysplugins/smarty_security.php ---------------------
@@ -19,6 +19,7 @@
/**
* This class does contain the security settings
*/
+#[\AllowDynamicProperties]
class Smarty_Security
{
/**
--------------------- libs/sysplugins/smarty_variable.php ---------------------
@@ -7,6 +7,7 @@
* @package Smarty
* @subpackage Template
*/
+#[\AllowDynamicProperties]
class Smarty_Variable
{
/**
PHP 8.2 sets HTML-ENTITIES deprecated and PHP 8.1 gave up ENT_COMPAT as default value for the triplet
Please double check if this is still operating as desired !!
Fix PHP 8.2 deprecation of flag HTML-ENTITIES ------------------- libs/plugins/modifiercompiler.escape.php -------------------
@@ -55,17 +55,17 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
// no break
case 'htmlall':
if (Smarty::$_MBSTRING) {
if ($_double_encode) {
// php >=5.2.3 - go native
- return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
- var_export($char_set, true) . ', ' . var_export($double_encode, true) .
- '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
+ return 'htmlspecialchars_decode(mb_convert_encoding(htmlentities(' . $params[ 0 ] . ', ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' .
+ var_export($char_set, true) . ', ' . var_export($double_encode, true) .
+ '), ' . var_export($char_set, true) . '))';
} elseif ($double_encode) {
// php <5.2.3 - only handle double encoding
- return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
- var_export($char_set, true) . '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
+ return 'htmlspecialchars_decode(mb_convert_encoding(htmlentities(' . $params[ 0 ] . ', ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' .
+ var_export($char_set, true) . '), ' . var_export($char_set, true) . '))';
} else {
// fall back to modifier.escape.php
}
}
// no MBString fallback
Fixed in #775