Make WordPress Core

Opened 21 months ago

Last modified 17 months ago

#50197 new defect (bug)

PHP 7.4 Compatibility with WP 5.4.1 – problem with seems_utf8()

Reported by: fohly Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4.1
Component: Formatting Keywords: close 2nd-opinion
Focuses: Cc:


Since I updated to PHP 7.4 I with the newest WordPress version 5.4.1 I am getting error notices when seems_utf8() from formatting.php is called with an integer as parameter. (This seems to happen when something around Buddypress (v 5.2) leads to calling this function and passes some integer id. I have not found the origin of this yet).

PHP 7.3 still seems to accept that and will still interpret $str[ $i ] in line 904.
From 7.4 this will lead to an error notice “Trying to access array offset on value of type int …”. In addition, after the error notice all special characters on the page rendered are not displayed correctly anymore.
Can you please prevent this from happening? A line in the beginning of the function like
$str = (string) $str;
can fix this error notice.
Maybe there is a more elegant way to prevent this, but I right now I don’t find it …

Best regards

Change History (2)

#1 @SergeyBiryukov
21 months ago

  • Component changed from General to Formatting
  • Keywords close 2nd-opinion added

Hi there, welcome to WordPress Trac! Thanks for the the report.

The docs for seems_utf8() clearly say that it accepts a string. If something passes an integer to it, that seems like a developer error, so the notice is appropriate. I don't think we should silently hide developer errors.

#2 @afragen
17 months ago

I've seen this error in my logs on occasion. The difficulty lies in figuring out what caused it. Any way to add a stack trace to the error message?

Note: See TracTickets for help on using tickets.