Changeset 55543
- Timestamp:
- 03/14/2023 03:51:28 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r55540 r55543 7015 7015 */ 7016 7016 function _get_non_cached_ids( $object_ids, $cache_key ) { 7017 $object_ids = array_filter( $object_ids, '_validate_cache_id' ); 7018 $object_ids = array_unique( array_map( 'intval', $object_ids ), SORT_NUMERIC ); 7019 7020 if ( empty( $object_ids ) ) { 7021 return array(); 7022 } 7023 7017 7024 $non_cached_ids = array(); 7018 7025 $cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); … … 7025 7032 7026 7033 return $non_cached_ids; 7034 } 7035 7036 /** 7037 * Checks whether the given cache ID is either an integer or iterger-like strings. 7038 * Both `16` and `"16"` are considered valid, other numeric types and numeric 7039 * strings (`16.3` and `"16.3"`) are considered invalid. 7040 * 7041 * @since 6.3.0 7042 * 7043 * @param mixed $object_id The cache id to validate. 7044 * @return bool Whether the given $object_id is a valid cache id. 7045 */ 7046 function _validate_cache_id( $object_id ) { 7047 // Unfortunately filter_var() is considered an optional extension 7048 if ( is_int( $object_id ) 7049 || ( is_string( $object_id ) && (string) (int) $object_id === $object_id ) ) { 7050 return true; 7051 } 7052 7053 /* translators: %s: The type of the given object id. */ 7054 $message = sprintf( __( 'Object id must be integer, %s given.' ), gettype( $object_id ) ); 7055 _doing_it_wrong( '_get_non_cached_ids', $message, '6.3.0' ); 7056 7057 return false; 7027 7058 } 7028 7059
Note: See TracChangeset
for help on using the changeset viewer.