cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
279 stars 83 forks source link

mb_convert_encoding() deprecation notice under PHP 8.2 #370

Closed cabrerahector closed 1 year ago

cabrerahector commented 1 year ago

Plugin is using mb_convert_encoding() in Output to fix some character encoding issues some users experience when using accented characters for example.

Under PHP 8.2, sites will start registering notices informing that "Handling HTML entities via mbstring is deprecated" (see PHP 8.2 Deprecation Warning in 6.2.1).

Potential solutions to test:

or

$html = iconv($charset, 'UTF-8', $html);
$html = mb_encode_numericentity($html, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8');

(link, which is somewhat similar to php.net's solution below)

(although this last one seems a little bit hard to read which might not be great for future code maintenance.)