From c6a3e08c3486de00f584f3fb8f8e2dba4730c00a Mon Sep 17 00:00:00 2001 From: alex-mailpoet Date: Wed, 25 Jan 2023 16:31:09 +0300 Subject: [PATCH] Fix soundasleep/html2text PHP 8.2 deprecation notices [MAILPOET-4875] --- mailpoet/tasks/fix-php82-deprecations.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mailpoet/tasks/fix-php82-deprecations.php b/mailpoet/tasks/fix-php82-deprecations.php index 5fda76ccbe..64c5ff9e85 100644 --- a/mailpoet/tasks/fix-php82-deprecations.php +++ b/mailpoet/tasks/fix-php82-deprecations.php @@ -18,6 +18,19 @@ $replacements = [ 'protected $backgroundColor = null;' . PHP_EOL . ' protected $background = null;' . PHP_EOL . ' /**', ], ], + [ + 'file' => __DIR__ . '/../vendor/soundasleep/html2text/src/Html2Text.php', + 'find' => [ + '$html = mb_convert_encoding($html, "HTML-ENTITIES", "UTF-8");', + ], + 'replace' => [ + '// HTML-ENTITIES mbstring encoder is deprecated since PHP 8.2,' . PHP_EOL . + "\t\t\t" . '// replaced by htmlentities() and htmlspecialchars_decode() as per' . PHP_EOL . + "\t\t\t" . '// https://php.watch/versions/8.2/mbstring-qprint-base64-uuencode-html-entities-deprecated#html' . PHP_EOL . + "\t\t\t" . '$html = htmlentities($html);' . PHP_EOL . + "\t\t\t" . '$html = htmlspecialchars_decode($html);', + ], + ], ]; // Apply replacements