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

PHP 8.2: Deprecation notices for dynamic properties #767

Closed
ophian opened this issue Jun 29, 2022 · 3 comments
Closed

PHP 8.2: Deprecation notices for dynamic properties #767

ophian opened this issue Jun 29, 2022 · 3 comments

Comments

@ophian
Copy link

ophian commented Jun 29, 2022

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.

@ophian
Copy link
Author

ophian commented Jul 7, 2022

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
 {
     /**

@ophian
Copy link
Author

ophian commented Jul 7, 2022

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

@wisskid
Copy link
Member

wisskid commented Nov 23, 2022

Fixed in #775

@wisskid wisskid closed this as completed Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants