General: Avoid a PHP warning when checking the `mbstring.func_overload` PHP value.

This avoids "A non-numeric value encountered" warning when `mbstring.func_overload` is set to something other than a numeric string, e.g. an empty string instead of the default `'0'` value.

Props djbu.
Fixes #53282.
Built from https://develop.svn.wordpress.org/trunk@51032


git-svn-id: http://core.svn.wordpress.org/trunk@50641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-05-26 16:05:59 +00:00
parent 60d7dcdc61
commit a30afc155e
3 changed files with 17 additions and 4 deletions

View File

@ -6862,7 +6862,13 @@ function mbstring_binary_safe_encoding( $reset = false ) {
static $overloaded = null; static $overloaded = null;
if ( is_null( $overloaded ) ) { if ( is_null( $overloaded ) ) {
$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ); // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated if ( function_exists( 'mb_internal_encoding' )
&& ( (int) ini_get( 'mbstring.func_overload' ) & 2 ) // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
) {
$overloaded = true;
} else {
$overloaded = false;
}
} }
if ( false === $overloaded ) { if ( false === $overloaded ) {

View File

@ -18,8 +18,15 @@ if ( ! class_exists( 'POMO_Reader', false ) ) :
* PHP5 constructor. * PHP5 constructor.
*/ */
function __construct() { function __construct() {
$this->is_overloaded = ( ( ini_get( 'mbstring.func_overload' ) & 2 ) != 0 ) && function_exists( 'mb_substr' ); // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated if ( function_exists( 'mb_substr' )
$this->_pos = 0; && ( (int) ini_get( 'mbstring.func_overload' ) & 2 ) // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
) {
$this->is_overloaded = true;
} else {
$this->is_overloaded = false;
}
$this->_pos = 0;
} }
/** /**

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.8-alpha-51031'; $wp_version = '5.8-alpha-51032';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.