mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Docs: Add a comment for stripping the leading AND from SQL clauses in some query classes.
Follow-up to [30084], [34529], [34542], [36598], [37477], [37572], [43010]. See #55646. git-svn-id: https://develop.svn.wordpress.org/trunk@53503 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
18d8db3078
commit
f3441e37ed
@ -911,7 +911,9 @@ class WP_Comment_Query {
|
||||
}
|
||||
|
||||
if ( ! empty( $this->query_vars['date_query'] ) && is_array( $this->query_vars['date_query'] ) ) {
|
||||
$this->date_query = new WP_Date_Query( $this->query_vars['date_query'], 'comment_date' );
|
||||
$this->date_query = new WP_Date_Query( $this->query_vars['date_query'], 'comment_date' );
|
||||
|
||||
// Strip leading 'AND'.
|
||||
$this->sql_clauses['where']['date_query'] = preg_replace( '/^\s*AND\s*/', '', $this->date_query->get_sql() );
|
||||
}
|
||||
|
||||
|
||||
@ -626,7 +626,9 @@ class WP_Site_Query {
|
||||
|
||||
$date_query = $this->query_vars['date_query'];
|
||||
if ( ! empty( $date_query ) && is_array( $date_query ) ) {
|
||||
$this->date_query = new WP_Date_Query( $date_query, 'registered' );
|
||||
$this->date_query = new WP_Date_Query( $date_query, 'registered' );
|
||||
|
||||
// Strip leading 'AND'.
|
||||
$this->sql_clauses['where']['date_query'] = preg_replace( '/^\s*AND\s*/', '', $this->date_query->get_sql() );
|
||||
}
|
||||
|
||||
|
||||
@ -484,6 +484,7 @@ class WP_Term_Query {
|
||||
if ( ! empty( $exclude_tree ) ) {
|
||||
$exclude_tree = wp_parse_id_list( $exclude_tree );
|
||||
$excluded_children = $exclude_tree;
|
||||
|
||||
foreach ( $exclude_tree as $extrunk ) {
|
||||
$excluded_children = array_merge(
|
||||
$excluded_children,
|
||||
@ -497,6 +498,7 @@ class WP_Term_Query {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$exclusions = array_merge( $excluded_children, $exclusions );
|
||||
}
|
||||
|
||||
@ -531,7 +533,7 @@ class WP_Term_Query {
|
||||
$exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args, $taxonomies );
|
||||
|
||||
if ( ! empty( $exclusions ) ) {
|
||||
// Must do string manipulation here for backward compatibility with filter.
|
||||
// Strip leading 'AND'. Must do string manipulation here for backward compatibility with filter.
|
||||
$this->sql_clauses['where']['exclusions'] = preg_replace( '/^\s*AND\s*/', '', $exclusions );
|
||||
}
|
||||
|
||||
@ -543,6 +545,7 @@ class WP_Term_Query {
|
||||
|
||||
if ( ! empty( $args['name'] ) ) {
|
||||
$names = $args['name'];
|
||||
|
||||
foreach ( $names as &$_name ) {
|
||||
// `sanitize_term_field()` returns slashed data.
|
||||
$_name = stripslashes( sanitize_term_field( 'name', $_name, 0, reset( $taxonomies ), 'db' ) );
|
||||
@ -650,9 +653,12 @@ class WP_Term_Query {
|
||||
$meta_clauses = $this->meta_query->get_clauses();
|
||||
|
||||
if ( ! empty( $meta_clauses ) ) {
|
||||
$join .= $mq_sql['join'];
|
||||
$join .= $mq_sql['join'];
|
||||
|
||||
// Strip leading 'AND'.
|
||||
$this->sql_clauses['where']['meta_query'] = preg_replace( '/^\s*AND\s*/', '', $mq_sql['where'] );
|
||||
$distinct .= 'DISTINCT';
|
||||
|
||||
$distinct .= 'DISTINCT';
|
||||
|
||||
}
|
||||
|
||||
@ -785,12 +791,16 @@ class WP_Term_Query {
|
||||
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'] ) ) {
|
||||
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 );
|
||||
}
|
||||
|
||||
_prime_term_caches( $term_ids, $args['update_term_meta_cache'] );
|
||||
|
||||
$term_objects = $this->populate_terms( $cache );
|
||||
$cache = $this->format_terms( $term_objects, $_fields );
|
||||
}
|
||||
@ -837,6 +847,7 @@ class WP_Term_Query {
|
||||
foreach ( $term_objects as $k => $term ) {
|
||||
if ( ! $term->count ) {
|
||||
$children = get_term_children( $term->term_id, $term->taxonomy );
|
||||
|
||||
if ( is_array( $children ) ) {
|
||||
foreach ( $children as $child_id ) {
|
||||
$child = get_term( $child_id, $term->taxonomy );
|
||||
@ -886,6 +897,7 @@ class WP_Term_Query {
|
||||
} else {
|
||||
$term_cache = wp_list_pluck( $term_objects, 'term_id' );
|
||||
}
|
||||
|
||||
wp_cache_add( $cache_key, $term_cache, 'terms' );
|
||||
$this->terms = $this->format_terms( $term_objects, $_fields );
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user