From ed4829b0eea7a6ba4e6c4a50c82d334594635368 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 14 Apr 2022 00:04:11 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-comment-query.php | 4 ++-- wp-includes/class-wp-network-query.php | 4 ++-- wp-includes/class-wp-query.php | 4 ++-- wp-includes/class-wp-site-query.php | 4 ++-- wp-includes/class-wp-term-query.php | 4 ++-- wp-includes/version.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/wp-includes/class-wp-comment-query.php b/wp-includes/class-wp-comment-query.php index 0531c00b7b..05aa4fb97e 100644 --- a/wp-includes/class-wp-comment-query.php +++ b/wp-includes/class-wp-comment-query.php @@ -917,7 +917,7 @@ class WP_Comment_Query { $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. @@ -927,7 +927,7 @@ class WP_Comment_Query { * @param string[] $clauses An associative array of comment query clauses. * @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'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; diff --git a/wp-includes/class-wp-network-query.php b/wp-includes/class-wp-network-query.php index ffdb956ad6..6c8712beff 100644 --- a/wp-includes/class-wp-network-query.php +++ b/wp-includes/class-wp-network-query.php @@ -438,7 +438,7 @@ class WP_Network_Query { $groupby = ''; - $clauses = compact( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); + $clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); /** * Filters the network query clauses. @@ -448,7 +448,7 @@ class WP_Network_Query { * @param string[] $clauses An associative array of network query clauses. * @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'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php index fbba6a5f31..6ae1674b71 100644 --- a/wp-includes/class-wp-query.php +++ b/wp-includes/class-wp-query.php @@ -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 @@ -2855,7 +2855,7 @@ class WP_Query { * } * @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'] : ''; $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : ''; diff --git a/wp-includes/class-wp-site-query.php b/wp-includes/class-wp-site-query.php index c405cf0ded..7beb930627 100644 --- a/wp-includes/class-wp-site-query.php +++ b/wp-includes/class-wp-site-query.php @@ -646,7 +646,7 @@ class WP_Site_Query { $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. @@ -656,7 +656,7 @@ class WP_Site_Query { * @param string[] $clauses An associative array of site query clauses. * @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'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; diff --git a/wp-includes/class-wp-term-query.php b/wp-includes/class-wp-term-query.php index 3c19849344..ba80b3639e 100644 --- a/wp-includes/class-wp-term-query.php +++ b/wp-includes/class-wp-term-query.php @@ -692,7 +692,7 @@ class WP_Term_Query { $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. @@ -703,7 +703,7 @@ class WP_Term_Query { * @param string[] $taxonomies An array of taxonomy names. * @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'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index b7b2028499..89b0245a57 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @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.