Make WordPress Core


Ignore:
Timestamp:
01/20/2016 08:01:55 AM (9 years ago)
Author:
dd32
Message:

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.

Location:
branches/4.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

  • branches/4.4/src/wp-includes/class-wp-comment-query.php

    r36357 r36361  
    759759                // $field_value may be an array.
    760760                $esses = array_fill( 0, count( (array) $field_value ), '%s' );
    761                 $this->sql_clauses['where']['post_fields'] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value );
     761                $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value );
    762762            }
    763763        }
Note: See TracChangeset for help on using the changeset viewer.