From 57d77853df3265d4612d7751d47d5539b53d1e1a Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Sun, 18 Sep 2022 17:53:13 +0200 Subject: [PATCH] Fixed PHP8.1 deprecation errors in strip_tags --- CHANGELOG.md | 1 + libs/plugins/modifiercompiler.strip_tags.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 460962d6..f5ca1e87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514) - Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801) +- Fixed PHP8.1 deprecation errors in strip_tags ## [4.2.1] - 2022-09-14 diff --git a/libs/plugins/modifiercompiler.strip_tags.php b/libs/plugins/modifiercompiler.strip_tags.php index 6ee3df9a..bd866a61 100644 --- a/libs/plugins/modifiercompiler.strip_tags.php +++ b/libs/plugins/modifiercompiler.strip_tags.php @@ -21,8 +21,8 @@ function smarty_modifiercompiler_strip_tags($params) { if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') { - return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; + return "preg_replace('!<[^>]*?>!', ' ', {$params[0]} ?: '')"; } else { - return 'strip_tags(' . $params[ 0 ] . ')'; + return 'strip_tags((string) ' . $params[ 0 ] . ')'; } }