diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 52c447d996..d7ad450680 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -4947,14 +4947,35 @@ function _wp_array_get( $input_array, $path, $default_value = null ) { } foreach ( $path as $path_element ) { - if ( - ! is_array( $input_array ) || - ( ! is_string( $path_element ) && ! is_integer( $path_element ) && ! is_null( $path_element ) ) || - ! array_key_exists( $path_element, $input_array ) - ) { + if ( ! is_array( $input_array ) ) { return $default_value; } - $input_array = $input_array[ $path_element ]; + + if ( is_string( $path_element ) + || is_integer( $path_element ) + || null === $path_element + ) { + /* + * Check if the path element exists in the input array. + * We check with `isset()` first, as it is a lot faster + * than `array_key_exists()`. + */ + if ( isset( $input_array[ $path_element ] ) ) { + $input_array = $input_array[ $path_element ]; + continue; + } + + /* + * If `isset()` returns false, we check with `array_key_exists()`, + * which also checks for `null` values. + */ + if ( array_key_exists( $path_element, $input_array ) ) { + $input_array = $input_array[ $path_element ]; + continue; + } + } + + return $default_value; } return $input_array; diff --git a/wp-includes/version.php b/wp-includes/version.php index 485ddcbdba..14e0ad7b47 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55850'; +$wp_version = '6.3-alpha-55851'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.