Changeset 34131
- Timestamp:
- 09/14/2015 10:03:23 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-functions.php
r34130 r34131 1917 1917 clean_post_cache( $post ); 1918 1918 1919 wp_cache_delete( "comments-{$post_id}", 'counts' ); 1920 1919 1921 /** 1920 1922 * Fires immediately after a post's comment count is updated in the database. … … 2325 2327 foreach ( (array) $ids as $id ) { 2326 2328 wp_cache_delete( $id, 'comment' ); 2327 wp_cache_delete( "comment-{$id}", 'counts' );2328 2329 } 2329 2330 -
trunk/tests/phpunit/tests/comment/wpCountComments.php
r33823 r34131 88 88 $this->assertEquals( 0, $count->total_comments ); 89 89 } 90 91 public function test_wp_count_comments_cache() { 92 $post_id = $this->factory->post->create( array( 93 'post_status' => 'publish' 94 ) ); 95 $comment_id = $this->factory->comment->create( array( 96 'comment_approved' => '1', 97 'comment_post_ID' => $post_id 98 ) ); 99 100 $count1 = wp_count_comments( $post_id ); 101 102 $this->assertEquals( 1, $count1->approved ); 103 $this->assertEquals( 0, $count1->moderated ); 104 $this->assertEquals( 0, $count1->spam ); 105 $this->assertEquals( 0, $count1->trash ); 106 $this->assertEquals( 0, $count1->{'post-trashed'} ); 107 $this->assertEquals( 1, $count1->total_comments ); 108 109 wp_spam_comment( $comment_id ); 110 $count2 = wp_count_comments( $post_id ); 111 112 $this->assertEquals( 0, $count2->approved ); 113 $this->assertEquals( 0, $count2->moderated ); 114 $this->assertEquals( 1, $count2->spam ); 115 $this->assertEquals( 0, $count2->trash ); 116 $this->assertEquals( 0, $count2->{'post-trashed'} ); 117 $this->assertEquals( 1, $count2->total_comments ); 118 119 wp_trash_comment( $comment_id ); 120 $count3 = wp_count_comments( $post_id ); 121 122 $this->assertEquals( 0, $count3->approved ); 123 $this->assertEquals( 0, $count3->moderated ); 124 $this->assertEquals( 0, $count3->spam ); 125 $this->assertEquals( 1, $count3->trash ); 126 $this->assertEquals( 0, $count3->{'post-trashed'} ); 127 $this->assertEquals( 0, $count3->total_comments ); 128 129 wp_untrash_comment( $comment_id ); 130 $count4 = wp_count_comments( $post_id ); 131 132 $this->assertEquals( 0, $count4->approved ); 133 $this->assertEquals( 0, $count4->moderated ); 134 $this->assertEquals( 1, $count4->spam ); 135 $this->assertEquals( 0, $count4->trash ); 136 $this->assertEquals( 0, $count4->{'post-trashed'} ); 137 $this->assertEquals( 1, $count4->total_comments ); 138 } 90 139 }
Note: See TracChangeset
for help on using the changeset viewer.