Make WordPress Core


Ignore:
Timestamp:
05/26/2021 04:04:50 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pomo/streams.php

    r49184 r51032  
    1919         */
    2020        function __construct() {
    21             $this->is_overloaded = ( ( ini_get( 'mbstring.func_overload' ) & 2 ) != 0 ) && function_exists( 'mb_substr' ); // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
    22             $this->_pos          = 0;
     21            if ( function_exists( 'mb_substr' )
     22                && ( (int) ini_get( 'mbstring.func_overload' ) & 2 ) // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
     23            ) {
     24                $this->is_overloaded = true;
     25            } else {
     26                $this->is_overloaded = false;
     27            }
     28
     29            $this->_pos = 0;
    2330        }
    2431
Note: See TracChangeset for help on using the changeset viewer.