WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/23/2020 05:22:39 AM (3 months ago)
Author:
whyisjake
Message:

Comments: Ensure the proper comment count and pages for unapproved comments.

Previiously, unapproved comments can alter the comment count, returning incorrect page numbers.

Fixes #8973.

Props GregMulhauser, dd32, ryan, mrmist, hakre, solarissmoke, billerickson, ericlewis, SergeyBiryukov, chriscct7, dossy, lukecavanagh, renggo888, jdorner, matjack1, pento, audrasjb, imath, davidbaumwald, whyisjake.

File:
1 edited

Legend:

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

    r48104 r48133  
    13311331 *
    13321332 * @since 1.5.0
     1333 * @since 5.5.0 Removed the need to use the $user_ID global.
    13331334 *
    13341335 * @global WP_Query   $wp_query         WordPress Query object.
     
    13381339 * @global WP_Comment $comment          Global comment object.
    13391340 * @global string     $user_login
    1340  * @global int        $user_ID
    13411341 * @global string     $user_identity
    13421342 * @global bool       $overridden_cpage
     
    13481348 */
    13491349function comments_template( $file = '/comments.php', $separate_comments = false ) {
    1350     global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
     1350    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_identity, $overridden_cpage;
    13511351
    13521352    if ( ! ( is_single() || is_page() || $withcomments ) || empty( $post ) ) {
     
    13971397    }
    13981398
    1399     if ( $user_ID ) {
    1400         $comment_args['include_unapproved'] = array( $user_ID );
    1401     } else {
    1402         $unapproved_email = wp_get_unapproved_comment_author_email();
    1403 
    1404         if ( $unapproved_email ) {
    1405             $comment_args['include_unapproved'] = array( $unapproved_email );
    1406         }
     1399    $include_unapproved = wp_get_include_unapproved_comments_argument();
     1400    if ( $include_unapproved ) {
     1401        $comment_args['include_unapproved'] = $include_unapproved;
    14071402    }
    14081403
Note: See TracChangeset for help on using the changeset viewer.