Merged in feature/81-dev-dev01 (pull request #5)

auto-patch  81-dev-dev01-2023-12-05T22_45_26

* auto-patch  81-dev-dev01-2023-12-05T22_45_26
This commit is contained in:
Tony Volpe
2023-12-05 23:05:59 +00:00
parent ba16964e7a
commit 725d3043d5
1463 changed files with 142461 additions and 89421 deletions

View File

@@ -91,6 +91,7 @@ class WP_Term_Query {
* @since 4.9.0 Added 'slug__in' support for 'orderby'.
* @since 5.1.0 Introduced the 'meta_compare_key' parameter.
* @since 5.3.0 Introduced the 'meta_type_key' parameter.
* @since 6.4.0 Introduced the 'cache_results' parameter.
*
* @param string|array $query {
* Optional. Array or query string of term query parameters. Default empty.
@@ -178,6 +179,7 @@ class WP_Term_Query {
* Default false.
* @type string $cache_domain Unique cache key to be produced when this query is stored in
* an object cache. Default 'core'.
* @type bool $cache_results Whether to cache term information. Default true.
* @type bool $update_term_meta_cache Whether to prime meta caches for matched terms. Default true.
* @type string|string[] $meta_key Meta key or keys to filter by.
* @type string|string[] $meta_value Meta value or values to filter by.
@@ -220,6 +222,7 @@ class WP_Term_Query {
'parent' => '',
'childless' => false,
'cache_domain' => 'core',
'cache_results' => true,
'update_term_meta_cache' => true,
'meta_query' => '',
'meta_key' => '',
@@ -738,6 +741,8 @@ class WP_Term_Query {
$order = isset( $clauses['order'] ) ? $clauses['order'] : '';
$limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
$fields_is_filtered = implode( ', ', $selects ) !== $fields;
if ( $where ) {
$where = "WHERE $where";
}
@@ -774,41 +779,47 @@ class WP_Term_Query {
return $this->terms;
}
$cache_key = $this->generate_cache_key( $args, $this->request );
$cache = wp_cache_get( $cache_key, 'term-queries' );
if ( $args['cache_results'] ) {
$cache_key = $this->generate_cache_key( $args, $this->request );
$cache = wp_cache_get( $cache_key, 'term-queries' );
if ( false !== $cache ) {
if ( 'ids' === $_fields ) {
$cache = array_map( 'intval', $cache );
} elseif ( 'count' !== $_fields ) {
if ( ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) )
|| ( 'all' === $_fields && $args['pad_counts'] )
) {
$term_ids = wp_list_pluck( $cache, 'term_id' );
} else {
$term_ids = array_map( 'intval', $cache );
if ( false !== $cache ) {
if ( 'ids' === $_fields ) {
$cache = array_map( 'intval', $cache );
} elseif ( 'count' !== $_fields ) {
if ( ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) )
|| ( 'all' === $_fields && $args['pad_counts'] || $fields_is_filtered )
) {
$term_ids = wp_list_pluck( $cache, 'term_id' );
} else {
$term_ids = array_map( 'intval', $cache );
}
_prime_term_caches( $term_ids, $args['update_term_meta_cache'] );
$term_objects = $this->populate_terms( $cache );
$cache = $this->format_terms( $term_objects, $_fields );
}
_prime_term_caches( $term_ids, $args['update_term_meta_cache'] );
$term_objects = $this->populate_terms( $cache );
$cache = $this->format_terms( $term_objects, $_fields );
$this->terms = $cache;
return $this->terms;
}
$this->terms = $cache;
return $this->terms;
}
if ( 'count' === $_fields ) {
$count = $wpdb->get_var( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
wp_cache_set( $cache_key, $count, 'term-queries' );
if ( $args['cache_results'] ) {
wp_cache_set( $cache_key, $count, 'term-queries' );
}
return $count;
}
$terms = $wpdb->get_results( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
if ( empty( $terms ) ) {
wp_cache_add( $cache_key, array(), 'term-queries' );
if ( $args['cache_results'] ) {
wp_cache_add( $cache_key, array(), 'term-queries' );
}
return array();
}
@@ -884,11 +895,16 @@ class WP_Term_Query {
$object->count = $term->count;
$term_cache[] = $object;
}
} elseif ( $fields_is_filtered ) {
$term_cache = $term_objects;
} else {
$term_cache = wp_list_pluck( $term_objects, 'term_id' );
}
wp_cache_add( $cache_key, $term_cache, 'term-queries' );
if ( $args['cache_results'] ) {
wp_cache_add( $cache_key, $term_cache, 'term-queries' );
}
$this->terms = $this->format_terms( $term_objects, $_fields );
return $this->terms;
@@ -1149,7 +1165,7 @@ class WP_Term_Query {
// $args can be anything. Only use the args defined in defaults to compute the key.
$cache_args = wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) );
unset( $cache_args['update_term_meta_cache'] );
unset( $cache_args['cache_results'], $cache_args['update_term_meta_cache'] );
if ( 'count' !== $args['fields'] && 'all_with_object_id' !== $args['fields'] ) {
$cache_args['fields'] = 'all';