Make WordPress Core


Ignore:
Timestamp:
04/27/2022 04:08:16 AM (4 years ago)
Author:
peterwilsoncc
Message:

Comments: Avoid DB error in comment meta queries.

In WP_Comment_Query always include the table name when referencing wp_comments.comment_ID. This avoids ambiguity in when making meta queries as wp_commentmeta includes a column of the same name.

Follow up to [47887].

Props genosseeinhorn, azouamauriac, audrasjb, peterwilsoncc.
Fixes #55218.

File:
1 edited

Legend:

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

    r53280 r53291  
    596596                                        if ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) {
    597597                                                // Only include requested comment.
    598                                                 $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' AND comment_ID = %d )", $unapproved_identifier, (int) $_GET['unapproved'] );
     598                                                $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' AND {$wpdb->comments}.comment_ID = %d )", $unapproved_identifier, (int) $_GET['unapproved'] );
    599599                                        } else {
    600600                                                // Include all of the author's unapproved comments.
Note: See TracChangeset for help on using the changeset viewer.