Make WordPress Core

Changeset 34161


Ignore:
Timestamp:
09/15/2015 01:46:51 AM (8 years ago)
Author:
wonderboymusic
Message:

In _wp_ajax_delete_comment_response(), read the new 'all' prop returned by get_comment_count() via wp_count_comments() when setting $total. 'all' doesn't include spam in its count.

Updates unit tests.

Props dipesh.kakadiya.
Fixes #32362.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r34130 r34161  
    372372    if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
    373373        $post_id = 0;
    374         $status = 'total_comments'; // What type of comment count are we looking for?
     374        // What type of comment count are we looking for?
     375        $status = 'all';
    375376        $parsed = parse_url( $url );
    376377        if ( isset( $parsed['query'] ) ) {
  • trunk/src/wp-includes/comment-functions.php

    r34158 r34161  
    363363        'post-trashed'        => 0,
    364364        'total_comments'      => 0,
     365        'all'                 => 0,
    365366    );
    366367
     
    380381                $comment_count['approved'] = $row['total'];
    381382                $comment_count['total_comments'] += $row['total'];
     383                $comment_count['all'] += $row['total'];
    382384                break;
    383385            case '0':
    384386                $comment_count['awaiting_moderation'] = $row['total'];
    385387                $comment_count['total_comments'] += $row['total'];
     388                $comment_count['all'] += $row['total'];
    386389                break;
    387390            default:
  • trunk/tests/phpunit/tests/comment/wpCountComments.php

    r34136 r34161  
    1212        $this->assertEquals( 0, $count->{'post-trashed'} );
    1313        $this->assertEquals( 0, $count->total_comments );
     14        $this->assertEquals( 0, $count->all );
    1415    }
    1516
     
    2728        $this->assertEquals( 0, $count->{'post-trashed'} );
    2829        $this->assertEquals( 1, $count->total_comments );
     30        $this->assertEquals( 1, $count->all );
    2931    }
    3032
     
    4244        $this->assertEquals( 0, $count->{'post-trashed'} );
    4345        $this->assertEquals( 1, $count->total_comments );
     46        $this->assertEquals( 1, $count->all );
    4447    }
    4548
     
    5760        $this->assertEquals( 0, $count->{'post-trashed'} );
    5861        $this->assertEquals( 1, $count->total_comments );
     62        $this->assertEquals( 0, $count->all );
    5963    }
    6064
     
    7276        $this->assertEquals( 0, $count->{'post-trashed'} );
    7377        $this->assertEquals( 0, $count->total_comments );
     78        $this->assertEquals( 0, $count->all );
    7479    }
    7580
     
    8792        $this->assertEquals( 1, $count->{'post-trashed'} );
    8893        $this->assertEquals( 0, $count->total_comments );
     94        $this->assertEquals( 0, $count->all );
    8995    }
    9096
     
    106112        $this->assertEquals( 0, $count1->{'post-trashed'} );
    107113        $this->assertEquals( 1, $count1->total_comments );
     114        $this->assertEquals( 1, $count1->all );
    108115
    109116        $all_count1 = wp_count_comments();
     
    115122        $this->assertEquals( 0, $all_count1->{'post-trashed'} );
    116123        $this->assertEquals( 1, $all_count1->total_comments );
     124        $this->assertEquals( 1, $all_count1->all );
    117125
    118126        wp_spam_comment( $comment_id );
     
    126134        $this->assertEquals( 0, $count2->{'post-trashed'} );
    127135        $this->assertEquals( 1, $count2->total_comments );
     136        $this->assertEquals( 0, $count2->all );
    128137
    129138        $all_count2 = wp_count_comments();
     
    135144        $this->assertEquals( 0, $all_count2->{'post-trashed'} );
    136145        $this->assertEquals( 1, $all_count2->total_comments );
     146        $this->assertEquals( 0, $all_count2->all );
    137147
    138148        wp_trash_comment( $comment_id );
     
    146156        $this->assertEquals( 0, $count3->{'post-trashed'} );
    147157        $this->assertEquals( 0, $count3->total_comments );
     158        $this->assertEquals( 0, $count3->all );
    148159
    149160        $all_count3 = wp_count_comments();
     
    155166        $this->assertEquals( 0, $all_count3->{'post-trashed'} );
    156167        $this->assertEquals( 0, $all_count3->total_comments );
     168        $this->assertEquals( 0, $all_count3->all );
    157169
    158170        wp_untrash_comment( $comment_id );
     
    166178        $this->assertEquals( 0, $count4->{'post-trashed'} );
    167179        $this->assertEquals( 1, $count4->total_comments );
     180        $this->assertEquals( 0, $count4->all );
    168181
    169182        $all_count4 = wp_count_comments();
     
    175188        $this->assertEquals( 0, $all_count4->{'post-trashed'} );
    176189        $this->assertEquals( 1, $all_count4->total_comments );
     190        $this->assertEquals( 0, $all_count4->all );
    177191    }
    178192}
Note: See TracChangeset for help on using the changeset viewer.