From 7baf5daba38288466f9db366a251b8c4c0b503f6 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 20 Jan 2016 08:02:26 +0000 Subject: [PATCH] Comments: Respect all post-related filters in `WP_Comment_Query`. The refactor of `WP_Comment_Query`'s SQL generation in [34542] introduced a bug that caused only the last post-related filter to be respected in comment queries. In other words, if querying for comments using params `post_status=draft&post_author=3`, only the last-processed of these params would be respected. The current changeset fixes the logic so that these clauses don't overwrite each other. Merges [36326] to the 4.4 branch. Props chriscct7. Fixes #35478. Built from https://develop.svn.wordpress.org/branches/4.4@36361 git-svn-id: http://core.svn.wordpress.org/branches/4.4@36328 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-comment-query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/class-wp-comment-query.php b/wp-includes/class-wp-comment-query.php index 7064d1690f..9f6aaa5327 100644 --- a/wp-includes/class-wp-comment-query.php +++ b/wp-includes/class-wp-comment-query.php @@ -758,7 +758,7 @@ class WP_Comment_Query { foreach ( $post_fields as $field_name => $field_value ) { // $field_value may be an array. $esses = array_fill( 0, count( (array) $field_value ), '%s' ); - $this->sql_clauses['where']['post_fields'] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value ); + $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value ); } }