[wp-trac] [WordPress Trac] #35478: 4.4 Regression on Querying for Comments by Multiple Post Fields
WordPress Trac
noreply at wordpress.org
Fri Jan 15 19:09:43 UTC 2016
#35478: 4.4 Regression on Querying for Comments by Multiple Post Fields
--------------------------+------------------------------------------
Reporter: chriscct7 | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: Awaiting Review
Component: Comments | Version: 4.4
Severity: major | Keywords: needs-patch needs-unit-tests
Focuses: |
--------------------------+------------------------------------------
In 4.4, there has been a regression in using WP_Comment_Query, and
querying by multiple post field parameters no longer works.
The cause is this loop that now processes post_fields:
{{{
if ( ! empty( $post_fields ) ) {
$join_posts_table = true;
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 );
}
}
}}}
On each iteration of this loop, the previous post_field query is thrown
out.
Thus a comment query by post_author and post_type will ignore the
post_author limiter.
This is caused by [34542] where before each forloop iteration resulted in
a new array index. Post [34542] this is not the case, causing the bug.
Additionally the docbloc on post_author is incorrect:
`Comment author ID to limit results by. Default empty.`
it should read
`Post author ID to limit results by. Default empty.`
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35478>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list