Coding Standards: Rename the `$clean` or `$ids` variable in several functions to `$non_cached_ids` for clarity.

* `_get_non_cached_ids()`
* `update_meta_cache()`
* `update_object_term_cache()`

See #49542.
Built from https://develop.svn.wordpress.org/trunk@48065


git-svn-id: http://core.svn.wordpress.org/trunk@47832 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-06-16 19:09:08 +00:00
parent c5ee065c3a
commit a8cd3a3e2c
4 changed files with 28 additions and 23 deletions

View File

@ -6359,16 +6359,16 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr
* @return int[] Array of IDs not present in the cache. * @return int[] Array of IDs not present in the cache.
*/ */
function _get_non_cached_ids( $object_ids, $cache_key ) { function _get_non_cached_ids( $object_ids, $cache_key ) {
$clean = array(); $non_cached_ids = array();
$cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); $cache_values = wp_cache_get_multiple( $object_ids, $cache_key );
foreach ( $cache_values as $id => $cache_value ) {
$id = (int) $id; foreach ( $cache_values as $id => $value ) {
if ( ! $cache_value ) { if ( ! $value ) {
$clean[] = $id; $non_cached_ids[] = (int) $id;
} }
} }
return $clean; return $non_cached_ids;
} }
/** /**

View File

@ -927,23 +927,24 @@ function update_meta_cache( $meta_type, $object_ids ) {
} }
$cache_key = $meta_type . '_meta'; $cache_key = $meta_type . '_meta';
$ids = array(); $non_cached_ids = array();
$cache = array(); $cache = array();
$cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); $cache_values = wp_cache_get_multiple( $object_ids, $cache_key );
foreach ( $cache_values as $id => $cached_object ) { foreach ( $cache_values as $id => $cached_object ) {
if ( false === $cached_object ) { if ( false === $cached_object ) {
$ids[] = $id; $non_cached_ids[] = $id;
} else { } else {
$cache[ $id ] = $cached_object; $cache[ $id ] = $cached_object;
} }
} }
if ( empty( $ids ) ) { if ( empty( $non_cached_ids ) ) {
return $cache; return $cache;
} }
// Get meta info. // Get meta info.
$id_list = join( ',', $ids ); $id_list = join( ',', $non_cached_ids );
$id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';
$meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A ); $meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A );
@ -967,7 +968,7 @@ function update_meta_cache( $meta_type, $object_ids ) {
} }
} }
foreach ( $ids as $id ) { foreach ( $non_cached_ids as $id ) {
if ( ! isset( $cache[ $id ] ) ) { if ( ! isset( $cache[ $id ] ) ) {
$cache[ $id ] = array(); $cache[ $id ] = array();
} }

View File

@ -3268,14 +3268,17 @@ function clean_term_cache( $ids, $taxonomy = '', $clean_taxonomy = true ) {
$tt_ids = implode( ', ', $tt_ids ); $tt_ids = implode( ', ', $tt_ids );
$terms = $wpdb->get_results( "SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)" ); $terms = $wpdb->get_results( "SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)" );
$ids = array(); $ids = array();
foreach ( (array) $terms as $term ) { foreach ( (array) $terms as $term ) {
$taxonomies[] = $term->taxonomy; $taxonomies[] = $term->taxonomy;
$ids[] = $term->term_id; $ids[] = $term->term_id;
wp_cache_delete( $term->term_id, 'terms' ); wp_cache_delete( $term->term_id, 'terms' );
} }
$taxonomies = array_unique( $taxonomies ); $taxonomies = array_unique( $taxonomies );
} else { } else {
$taxonomies = array( $taxonomy ); $taxonomies = array( $taxonomy );
foreach ( $taxonomies as $taxonomy ) { foreach ( $taxonomies as $taxonomy ) {
foreach ( $ids as $id ) { foreach ( $ids as $id ) {
wp_cache_delete( $id, 'terms' ); wp_cache_delete( $id, 'terms' );
@ -3406,26 +3409,27 @@ function update_object_term_cache( $object_ids, $object_type ) {
} }
$object_ids = array_map( 'intval', $object_ids ); $object_ids = array_map( 'intval', $object_ids );
$non_cached_ids = array();
$taxonomies = get_object_taxonomies( $object_type ); $taxonomies = get_object_taxonomies( $object_type );
$ids = array();
foreach ( $taxonomies as $taxonomy ) { foreach ( $taxonomies as $taxonomy ) {
$cache_values = wp_cache_get_multiple( (array) $object_ids, "{$taxonomy}_relationships" ); $cache_values = wp_cache_get_multiple( (array) $object_ids, "{$taxonomy}_relationships" );
foreach ( $cache_values as $key => $value ) {
foreach ( $cache_values as $id => $value ) {
if ( false === $value ) { if ( false === $value ) {
$ids[] = $key; $non_cached_ids[] = $id;
break; break;
} }
} }
} }
if ( empty( $ids ) ) { if ( empty( $non_cached_ids ) ) {
return false; return false;
} }
$terms = wp_get_object_terms( $terms = wp_get_object_terms(
$ids, $non_cached_ids,
$taxonomies, $taxonomies,
array( array(
'fields' => 'all_with_object_id', 'fields' => 'all_with_object_id',
@ -3439,7 +3443,7 @@ function update_object_term_cache( $object_ids, $object_type ) {
$object_terms[ $term->object_id ][ $term->taxonomy ][] = $term->term_id; $object_terms[ $term->object_id ][ $term->taxonomy ][] = $term->term_id;
} }
foreach ( $ids as $id ) { foreach ( $non_cached_ids as $id ) {
foreach ( $taxonomies as $taxonomy ) { foreach ( $taxonomies as $taxonomy ) {
if ( ! isset( $object_terms[ $id ][ $taxonomy ] ) ) { if ( ! isset( $object_terms[ $id ][ $taxonomy ] ) ) {
if ( ! isset( $object_terms[ $id ] ) ) { if ( ! isset( $object_terms[ $id ] ) ) {

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.5-alpha-48064'; $wp_version = '5.5-alpha-48065';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.