Changeset 55083 for trunk/src/wp-includes/class-wp-term-query.php
- Timestamp:
- 01/18/2023 09:56:55 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-term-query.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-term-query.php
r54867 r55083 775 775 } 776 776 777 // $args can be anything. Only use the args defined in defaults to compute the key. 778 $cache_args = wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) ); 779 780 unset( $cache_args['update_term_meta_cache'] ); 781 782 if ( 'count' !== $_fields && 'all_with_object_id' !== $_fields ) { 783 $cache_args['fields'] = 'all'; 784 } 785 786 $key = md5( serialize( $cache_args ) . serialize( $taxonomies ) . $this->request ); 787 $last_changed = wp_cache_get_last_changed( 'terms' ); 788 $cache_key = "get_terms:$key:$last_changed"; 789 $cache = wp_cache_get( $cache_key, 'terms' ); 777 $cache_key = $this->generate_cache_key( $args, $this->request ); 778 $cache = wp_cache_get( $cache_key, 'terms' ); 790 779 791 780 if ( false !== $cache ) { … … 1143 1132 return $term_objects; 1144 1133 } 1134 1135 /** 1136 * Generate cache key. 1137 * 1138 * @since 6.2.0 1139 * 1140 * @global wpdb $wpdb WordPress database abstraction object. 1141 * 1142 * @param array $args WP_Term_Query arguments. 1143 * @param string $sql SQL statement. 1144 * 1145 * @return string Cache key. 1146 */ 1147 protected function generate_cache_key( array $args, $sql ) { 1148 global $wpdb; 1149 // $args can be anything. Only use the args defined in defaults to compute the key. 1150 $cache_args = wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) ); 1151 1152 unset( $cache_args['update_term_meta_cache'] ); 1153 1154 if ( 'count' !== $args['fields'] && 'all_with_object_id' !== $args['fields'] ) { 1155 $cache_args['fields'] = 'all'; 1156 } 1157 $taxonomies = (array) $args['taxonomy']; 1158 1159 // Replace wpdb placeholder in the SQL statement used by the cache key. 1160 $sql = $wpdb->remove_placeholder_escape( $sql ); 1161 1162 $key = md5( serialize( $cache_args ) . serialize( $taxonomies ) . $sql ); 1163 $last_changed = wp_cache_get_last_changed( 'terms' ); 1164 return "get_terms:$key:$last_changed"; 1165 } 1145 1166 }
Note: See TracChangeset
for help on using the changeset viewer.