WordPress.org

Make WordPress Core

Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#46143 closed defect (bug) (worksforme)

UTF8 typo, but

Reported by: masterross Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.0.3
Component: Charset Keywords:
Focuses: Cc:

Description

Hi,

It looks like there is a typo (bug) in function wp_encode_emoji()

in line 5125 on /wp-includes/formatting.php :

<?php
function wp_encode_emoji( $content ) {
        $emoji = _wp_emoji_list( 'partials' );

        foreach ( $emoji as $emojum ) {
                if ( version_compare( phpversion(), '5.4', '<' ) ) {
                        $emoji_char = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' );
                } else {
                        $emoji_char = html_entity_decode( $emojum );
                }
                if ( false !== strpos( $content, $emoji_char ) ) {
                        $content = preg_replace( "/$emoji_char/", $emojum, $content );
                }
        }

        return $content;
}

'<' should be '>'

I found it when I check our error log filled with:

UTF-8;’ not supported, assuming utf-8 in /home/ladylen/public_html/blog/wp-includes/formatting.php on line 5125
[29-Jan-2019 16:05:16 UTC] PHP Warning: html_entity_decode(): charset `UTF-8;’ not supported, assuming utf-8 in /home/ladylen/public_html/blog/wp-includes/formatting.php on line 5125
[29-Jan-2019 16:05:16 UTC] PHP Warning: html_entity_decode(): charset `UTF-8;’ not supported, assuming utf-8 in /home/ladylen/public_html/blog/wp-includes/formatting.php on line 5125
[29-Jan-2019 16:05:16 UTC] PHP Warning: html_entity_decode(): charset `UTF-8;’ not supported, assuming utf-8 in /home/ladylen/public_html/blog/wp-includes/formatting.php on line 5125
[29-Jan-2019 16:05:16 UTC] PHP Warning: html_entity_decode(): charset `UTF-8;’ not supported, assuming utf-8 in /home/ladylen/public_html/blog/wp-includes/formatting.php on line 5125
[29-Jan-2019 16:05:16 UTC] PHP Warning: html_entity_decode(): charset `UTF-8;’ not supported, assuming utf-8 in /home/ladylen/public_html/blog/wp-includes/formatting.php on line 5125
[29-Jan-2019 16:05:16 UTC] PHP Warning: html_entity_decode(): charset `UTF-8;’ not supported, assuming utf-8 in /home/ladylen/public_html/blog/wp-includes/formatting.php on line 5125


Change History (3)

#1 @ayeshrajans
8 months ago

Hello @masterross - Welcome to WordPress Trac!
Current approach is correct. Prior to PHP 5.4, the default encoding was ISO-8859-1 (yuck!), so this workaround was needed.

Looking at the error message, it looks like you have an error in your php.ini settings: UTF-8;’. Notice the unnecessary semicolon. You will need to find where this is set (a php.ini file or an ini_set call for default_charset directive) and remove the semicolon.

Last edited 8 months ago by ayeshrajans (previous) (diff)

#2 @masterross
8 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

Hi @ayeshrajans,
You were right!
I'm using PHP 5.6 and 7.2 and in 5.6 I was forget to uncomment default_charset.

thank you for the hint!

#3 @desrosj
8 months ago

  • Milestone Awaiting Review deleted

Removing Awaiting Review milestone from closed tickets.

Note: See TracTickets for help on using tickets.