diff --git a/wp-includes/compat.php b/wp-includes/compat.php index 84e611faee..864c410620 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -48,8 +48,28 @@ function _wp_can_use_pcre_u( $set = null ) { } if ( 'reset' === $utf8_pcre ) { - // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- intentional error generated to detect PCRE/u support. - $utf8_pcre = @preg_match( '/^./u', 'a' ); + $utf8_pcre = true; + + set_error_handler( + function ( $errno, $errstr ) use ( &$utf8_pcre ) { + if ( str_starts_with( $errstr, 'preg_match():' ) ) { + $utf8_pcre = false; + return true; + } + + return false; + }, + E_WARNING + ); + + /* + * Attempt to compile a PCRE pattern with the PCRE_UTF8 flag. For + * systems lacking Unicode support this will trigger a warning + * during compilation, which the error handler will intercept. + */ + preg_match( '//u', '' ); + + restore_error_handler(); } return $utf8_pcre; diff --git a/wp-includes/version.php b/wp-includes/version.php index b23a19c182..5489863251 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.9-alpha-60693'; +$wp_version = '6.9-alpha-60694'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.