Query: Restore late `compact()` call for SQL clauses in `wp-includes/class-wp-*-query.php`.

This addresses a backward compatibility break where `posts_groupby` and other filters were applied, but their results were subsequently discarded and earlier values were used instead.

Follow-up to [52974].

Props nextend_ramona.
See #54728, #meta6273.
Built from https://develop.svn.wordpress.org/trunk@53175


git-svn-id: http://core.svn.wordpress.org/trunk@52764 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-04-14 00:04:11 +00:00
parent c6a5a33e54
commit ed4829b0ee
6 changed files with 11 additions and 11 deletions

View File

@ -917,7 +917,7 @@ class WP_Comment_Query {
$where = implode( ' AND ', $this->sql_clauses['where'] ); $where = implode( ' AND ', $this->sql_clauses['where'] );
$clauses = compact( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); $clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
/** /**
* Filters the comment query clauses. * Filters the comment query clauses.
@ -927,7 +927,7 @@ class WP_Comment_Query {
* @param string[] $clauses An associative array of comment query clauses. * @param string[] $clauses An associative array of comment query clauses.
* @param WP_Comment_Query $query Current instance of WP_Comment_Query (passed by reference). * @param WP_Comment_Query $query Current instance of WP_Comment_Query (passed by reference).
*/ */
$clauses = apply_filters_ref_array( 'comments_clauses', array( $clauses, &$this ) ); $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $clauses ), &$this ) );
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
$join = isset( $clauses['join'] ) ? $clauses['join'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : '';

View File

@ -438,7 +438,7 @@ class WP_Network_Query {
$groupby = ''; $groupby = '';
$clauses = compact( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); $clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
/** /**
* Filters the network query clauses. * Filters the network query clauses.
@ -448,7 +448,7 @@ class WP_Network_Query {
* @param string[] $clauses An associative array of network query clauses. * @param string[] $clauses An associative array of network query clauses.
* @param WP_Network_Query $query Current instance of WP_Network_Query (passed by reference). * @param WP_Network_Query $query Current instance of WP_Network_Query (passed by reference).
*/ */
$clauses = apply_filters_ref_array( 'networks_clauses', array( $clauses, &$this ) ); $clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $clauses ), &$this ) );
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
$join = isset( $clauses['join'] ) ? $clauses['join'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : '';

View File

@ -2753,7 +2753,7 @@ class WP_Query {
} }
} }
$clauses = compact( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' ); $clauses = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' );
/* /*
* Apply post-paging filters on where and join. Only plugins that * Apply post-paging filters on where and join. Only plugins that
@ -2855,7 +2855,7 @@ class WP_Query {
* } * }
* @param WP_Query $query The WP_Query instance (passed by reference). * @param WP_Query $query The WP_Query instance (passed by reference).
*/ */
$clauses = (array) apply_filters_ref_array( 'posts_clauses', array( $clauses, &$this ) ); $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $clauses ), &$this ) );
$where = isset( $clauses['where'] ) ? $clauses['where'] : ''; $where = isset( $clauses['where'] ) ? $clauses['where'] : '';
$groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : ''; $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';

View File

@ -646,7 +646,7 @@ class WP_Site_Query {
$where = implode( ' AND ', $this->sql_clauses['where'] ); $where = implode( ' AND ', $this->sql_clauses['where'] );
$clauses = compact( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); $clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
/** /**
* Filters the site query clauses. * Filters the site query clauses.
@ -656,7 +656,7 @@ class WP_Site_Query {
* @param string[] $clauses An associative array of site query clauses. * @param string[] $clauses An associative array of site query clauses.
* @param WP_Site_Query $query Current instance of WP_Site_Query (passed by reference). * @param WP_Site_Query $query Current instance of WP_Site_Query (passed by reference).
*/ */
$clauses = apply_filters_ref_array( 'sites_clauses', array( $clauses, &$this ) ); $clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $clauses ), &$this ) );
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
$join = isset( $clauses['join'] ) ? $clauses['join'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : '';

View File

@ -692,7 +692,7 @@ class WP_Term_Query {
$where = implode( ' AND ', $this->sql_clauses['where'] ); $where = implode( ' AND ', $this->sql_clauses['where'] );
$clauses = compact( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' ); $clauses = array( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' );
/** /**
* Filters the terms query SQL clauses. * Filters the terms query SQL clauses.
@ -703,7 +703,7 @@ class WP_Term_Query {
* @param string[] $taxonomies An array of taxonomy names. * @param string[] $taxonomies An array of taxonomy names.
* @param array $args An array of term query arguments. * @param array $args An array of term query arguments.
*/ */
$clauses = apply_filters( 'terms_clauses', $clauses, $taxonomies, $args ); $clauses = apply_filters( 'terms_clauses', compact( $clauses ), $taxonomies, $args );
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
$join = isset( $clauses['join'] ) ? $clauses['join'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : '';

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.0-beta1-53174'; $wp_version = '6.0-beta1-53175';
/** /**
* 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.