Make WordPress Core


Ignore:
Timestamp:
06/06/2020 09:58:55 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Comments: Ensure that unmoderated comments won't be search indexed.

After a comment is submitted, only allow a brief window where the comment is live on the site.

Props jonkolbert, ayeshrajans, Asif2BD, peterwilsoncc, imath, audrasjb, jonoaldersonwp, whyisjake, SergeyBiryukov.
Merges [47887] and [47889] to the 5.2 branch.
See #49956.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

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

    r44573 r47917  
    528528                if ( is_numeric( $unapproved_identifier ) ) {
    529529                    $approved_clauses[] = $wpdb->prepare( "( user_id = %d AND comment_approved = '0' )", $unapproved_identifier );
    530 
     530                } else {
    531531                    // Otherwise we match against email addresses.
    532                 } else {
    533                     $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier );
     532                    if ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) {
     533                        // Only include requested comment.
     534                        $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' AND comment_ID = %d )", $unapproved_identifier, (int) $_GET['unapproved'] );
     535                    } else {
     536                        // Include all of the author's unapproved comments.
     537                        $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier );
     538                    }
    534539                }
    535540            }
Note: See TracChangeset for help on using the changeset viewer.