diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 8a02df2d5c..e3e281b1d6 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -7014,6 +7014,13 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr * @return int[] Array of IDs not present in the cache. */ function _get_non_cached_ids( $object_ids, $cache_key ) { + $object_ids = array_filter( $object_ids, '_validate_cache_id' ); + $object_ids = array_unique( array_map( 'intval', $object_ids ), SORT_NUMERIC ); + + if ( empty( $object_ids ) ) { + return array(); + } + $non_cached_ids = array(); $cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); @@ -7026,6 +7033,30 @@ function _get_non_cached_ids( $object_ids, $cache_key ) { return $non_cached_ids; } +/** + * Checks whether the given cache ID is either an integer or iterger-like strings. + * Both `16` and `"16"` are considered valid, other numeric types and numeric + * strings (`16.3` and `"16.3"`) are considered invalid. + * + * @since 6.3.0 + * + * @param mixed $object_id The cache id to validate. + * @return bool Whether the given $object_id is a valid cache id. + */ +function _validate_cache_id( $object_id ) { + // Unfortunately filter_var() is considered an optional extension + if ( is_int( $object_id ) + || ( is_string( $object_id ) && (string) (int) $object_id === $object_id ) ) { + return true; + } + + /* translators: %s: The type of the given object id. */ + $message = sprintf( __( 'Object id must be integer, %s given.' ), gettype( $object_id ) ); + _doing_it_wrong( '_get_non_cached_ids', $message, '6.3.0' ); + + return false; +} + /** * Tests if the current device has the capability to upload files. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 4f21f7bace..3c8e2b7992 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55542'; +$wp_version = '6.3-alpha-55543'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.