[wp-trac] [WordPress Trac] #63066: Warning when array passed to wp_check_invalid_utf8()
WordPress Trac
noreply at wordpress.org
Mon Aug 11 21:16:34 UTC 2025
#63066: Warning when array passed to wp_check_invalid_utf8()
--------------------------+------------------------------
Reporter: leedxw | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 6.7.2
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by dmsnell):
@garrigan I would be reluctant to add random type checks to this function
whose documentation already indicates that `$text` ought to be a string.
if anything, if we want to perform the runtime type-checking we would want
to ask for what we want rather than what we don’t want, e.g. `if ( !
is_string( $text ) ) { return ''; }`
it appears, however, that the problem is likely higher up in the call
stack; something is calling `wp_check_invalid_utf8()` improperly. are you
able to to log what this is?
if you are able to recreate the error condition then you can temporarily
modify the WordPress file to get out the data and call stack.
{{{#!php
<?php
function wp_check_invalid_utf8( $text, $strip = false ) {
if ( is_array( $text ) ) {
var_dump( $text );
throw new Error( 'should only be passing string; not array
to wp_check_invalid_utf8()' );
}
$text = (string) $text;
…
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63066#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list