From eff94648d7fa343c0ef0394f02674bc5e555ff20 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 16 Jun 2020 19:07:04 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@48065 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 14 +++++++------- src/wp-includes/meta.php | 17 +++++++++-------- src/wp-includes/taxonomy.php | 18 +++++++++++------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 2895a03cbb..022caadb16 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -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. */ function _get_non_cached_ids( $object_ids, $cache_key ) { - $clean = array(); - $cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); - foreach ( $cache_values as $id => $cache_value ) { - $id = (int) $id; - if ( ! $cache_value ) { - $clean[] = $id; + $non_cached_ids = array(); + $cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); + + foreach ( $cache_values as $id => $value ) { + if ( ! $value ) { + $non_cached_ids[] = (int) $id; } } - return $clean; + return $non_cached_ids; } /** diff --git a/src/wp-includes/meta.php b/src/wp-includes/meta.php index c34e724db2..01912e123c 100644 --- a/src/wp-includes/meta.php +++ b/src/wp-includes/meta.php @@ -926,24 +926,25 @@ function update_meta_cache( $meta_type, $object_ids ) { return (bool) $check; } - $cache_key = $meta_type . '_meta'; - $ids = array(); - $cache = array(); - $cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); + $cache_key = $meta_type . '_meta'; + $non_cached_ids = array(); + $cache = array(); + $cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); + foreach ( $cache_values as $id => $cached_object ) { if ( false === $cached_object ) { - $ids[] = $id; + $non_cached_ids[] = $id; } else { $cache[ $id ] = $cached_object; } } - if ( empty( $ids ) ) { + if ( empty( $non_cached_ids ) ) { return $cache; } // Get meta info. - $id_list = join( ',', $ids ); + $id_list = join( ',', $non_cached_ids ); $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 ); @@ -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 ] ) ) { $cache[ $id ] = array(); } diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index b8bbc5048b..751e6cadff 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -3268,14 +3268,17 @@ function clean_term_cache( $ids, $taxonomy = '', $clean_taxonomy = true ) { $tt_ids = implode( ', ', $tt_ids ); $terms = $wpdb->get_results( "SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)" ); $ids = array(); + foreach ( (array) $terms as $term ) { $taxonomies[] = $term->taxonomy; $ids[] = $term->term_id; wp_cache_delete( $term->term_id, 'terms' ); } + $taxonomies = array_unique( $taxonomies ); } else { $taxonomies = array( $taxonomy ); + foreach ( $taxonomies as $taxonomy ) { foreach ( $ids as $id ) { wp_cache_delete( $id, 'terms' ); @@ -3405,27 +3408,28 @@ function update_object_term_cache( $object_ids, $object_type ) { $object_ids = explode( ',', $object_ids ); } - $object_ids = array_map( 'intval', $object_ids ); + $object_ids = array_map( 'intval', $object_ids ); + $non_cached_ids = array(); $taxonomies = get_object_taxonomies( $object_type ); - $ids = array(); foreach ( $taxonomies as $taxonomy ) { $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 ) { - $ids[] = $key; + $non_cached_ids[] = $id; break; } } } - if ( empty( $ids ) ) { + if ( empty( $non_cached_ids ) ) { return false; } $terms = wp_get_object_terms( - $ids, + $non_cached_ids, $taxonomies, array( '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; } - foreach ( $ids as $id ) { + foreach ( $non_cached_ids as $id ) { foreach ( $taxonomies as $taxonomy ) { if ( ! isset( $object_terms[ $id ][ $taxonomy ] ) ) { if ( ! isset( $object_terms[ $id ] ) ) {