WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/15/2016 08:09:36 PM (5 years ago)
Author:
boonebgorges
Message:

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.

Props chriscct7.
Fixes #35478.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-comment-query.php

    r36277 r36326  
    766766                // $field_value may be an array.
    767767                $esses = array_fill( 0, count( (array) $field_value ), '%s' );
    768                 $this->sql_clauses['where']['post_fields'] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value );
     768                $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value );
    769769            }
    770770        }
Note: See TracChangeset for help on using the changeset viewer.