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.1 deprecated warning for ParsedownExtra.php in core #1801

Closed
jjozsi opened this issue Aug 22, 2023 · 2 comments
Closed

PHP 8.1 deprecated warning for ParsedownExtra.php in core #1801

jjozsi opened this issue Aug 22, 2023 · 2 comments

Comments

@jjozsi
Copy link

jjozsi commented Aug 22, 2023

The Parsedown Extra library causes a PHP deprecated error in PHP 8.1 or later:

Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in /wire/modules/Textformatter/TextformatterMarkdownExtra/parsedown-extra/ParsedownExtra.php

The 2.0 branch of the library seem to have fixed this: erusev/parsedown-extra#173 but I wouldn't know how to integrate the 2.0.x versions (Parsedown and Parsedown Extra) into the module.

Temporary fix:
Replacing line #628 with the following makes the warning go away:
$elementMarkup = htmlspecialchars_decode(iconv('UTF-8', 'ISO-8859-1', htmlentities($elementMarkup, ENT_COMPAT, 'UTF-8')), ENT_QUOTES);
The above solution was found in the following Drupal thread: https://www.drupal.org/project/smart_trim/issues/3342481

ryancramerdesign added a commit to processwire/processwire that referenced this issue Aug 22, 2023
@ryancramerdesign
Copy link
Member

Thanks @jjozsi I've pushed a fix for this. I omitted the iconv() part because we're not working with ISO-8859-1, but also that call gave me an error.

@jjozsi
Copy link
Author

jjozsi commented Aug 22, 2023

Thanks Ryan, I tested it and I have no warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants