Site logo

Archived topic

formatting.php - Recoverable fatal error: Object of class WP_Error

5 replies · Started by erdinc on December 12, 2019

Viewing posts 1–6 of 6

wordpress getting error how to solve ?

Recoverable fatal error: Object of class WP_Error could not be converted to string in /srv/users/serverpilot/apps/amavideniz/public/wp-includes/formatting.php on line 1115

/**
* Checks for invalid UTF8 in a string.
*
* @since 2.8.0
*
* @staticvar bool $is_utf8
* @staticvar bool $utf8_pcre
*
* @param string $string The text which is to be checked.
* @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
* @return string The checked text.
*/
function wp_check_invalid_utf8( $string, $strip = false ) {
$string = (string) $string;

if ( 0 === strlen( $string ) ) {
return '';
}

// Store the site charset as a static to avoid multiple calls to get_option()
static $is_utf8 = null;
if ( ! isset( $is_utf8 ) ) {
$is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) );
}
if ( ! $is_utf8 ) {
return $string;
}

// Check for support for utf8 in the installed PCRE library once and store the result in a static
static $utf8_pcre = null;
if ( ! isset( $utf8_pcre ) ) {
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
$utf8_pcre = @preg_match( '/^./u', 'a' );
}
// We can't demand utf8 in the PCRE installation, so just return the string in those cases
if ( ! $utf8_pcre ) {
return $string;
}

// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- preg_match fails when it encounters invalid UTF8 in $string
if ( 1 === @preg_match( '/^./us', $string ) ) {
return $string;
}

// Attempt to strip the bad chars if requested (not recommended)
if ( $strip && function_exists( 'iconv' ) ) {
return iconv( 'utf-8', 'utf-8', $string );
}

return '';
}

Hi there,

that error relates to a WordPress function and it means that a plugin or custom function is using it incorrectly. Debug by disabling plugins and removing custom functions to find the culprit.

solved plugin problem

Glad to hear that.
Can you share what plugin - other users may find it helpful.

Yoast SEO plugins

Well i wasn't expecting that - thanks for letting us know

This archived topic is closed to new replies.