Make WordPress Core

Changeset 48133

Timestamp:
06/23/2020 05:22:39 AM (4 years 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.

Location:
trunk
Files:
3 edited

Legend:

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

    r48104 r48133  
    13311331 *
    13321332 * @since 1.5.0
     1333
    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
  • trunk/src/wp-includes/comment.php

    r48121 r48133  
    11331133        );
    11341134
     1135
     1136
     1137
     1138
     1139
     1140
     1141
     1142
     1143
     1144
     1145
     1146
     1147
     1148
     1149
     1150
     1151
     1152
     1153
     1154
     1155
     1156
     1157
     1158
     1159
     1160
     1161
     1162
     1163
     1164
    11351165        $comment_query       = new WP_Comment_Query();
    11361166        $older_comment_count = $comment_query->query( $comment_args );
     
    18951925
    18961926    return $commenter_email;
     1927
     1928
     1929
     1930
     1931
     1932
     1933
     1934
     1935
     1936
     1937
     1938
     1939
     1940
     1941
     1942
     1943
     1944
     1945
     1946
     1947
     1948
     1949
     1950
     1951
     1952
     1953
    18971954}
    18981955
  • trunk/tests/phpunit/tests/comment/getPageOfComment.php

    r47122 r48133  
    440440        $this->assertEquals( 2, get_page_of_comment( $c3 ) );
    441441    }
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
     503
     504
     505
     506
     507
     508
     509
     510
     511
     512
     513
     514
     515
     516
     517
     518
     519
     520
     521
     522
     523
     524
     525
     526
     527
     528
     529
     530
     531
     532
     533
     534
     535
     536
     537
     538
     539
     540
     541
     542
     543
     544
     545
     546
     547
     548
    442549}
Note: See TracChangeset for help on using the changeset viewer.