Make WordPress Core

Changeset 51032


Ignore:
Timestamp:
05/26/2021 04:04:50 PM (5 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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r50965 r51032  
    68636863
    68646864        if ( is_null( $overloaded ) ) {
    6865                 $overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ); // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
     6865                if ( function_exists( 'mb_internal_encoding' )
     6866                        && ( (int) ini_get( 'mbstring.func_overload' ) & 2 ) // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
     6867                ) {
     6868                        $overloaded = true;
     6869                } else {
     6870                        $overloaded = false;
     6871                }
    68666872        }
    68676873
  • 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.