Opened 8 months ago
Last modified 5 months ago
#50197 new defect (bug)
PHP 7.4 Compatibility with WP 5.4.1 – problem with seems_utf8()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.4.1 |
Component: | Formatting | Keywords: | close 2nd-opinion |
Focuses: | Cc: |
Description
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
Florian
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.