| | 91 | * @ticket 40669 |
| | 92 | */ |
| | 93 | public function test_comment_meta_cache_invalidation() { |
| | 94 | global $wpdb; |
| | 95 | |
| | 96 | $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| | 97 | $comment_ids = self::factory()->comment->create_post_comments( $p, 3 ); |
| | 98 | $other_comment_ids = self::factory()->comment->create_post_comments( $p, 2 ); |
| | 99 | foreach ( $comment_ids as $cid ) { |
| | 100 | add_comment_meta( $cid, 'sauce', 'fire' ); |
| | 101 | } |
| | 102 | |
| | 103 | $this->assertSame( 3, get_comments( array( |
| | 104 | 'post_id' => $p, |
| | 105 | 'count' => true, |
| | 106 | 'meta_query' => array( |
| | 107 | array( |
| | 108 | 'key' => 'sauce', |
| | 109 | 'value' => 'fire' |
| | 110 | ), |
| | 111 | ) |
| | 112 | ) ) ); |
| | 113 | $this->assertSame( 3, get_comments( array( |
| | 114 | 'post_id' => $p, |
| | 115 | 'count' => true, |
| | 116 | 'meta_query' => array( |
| | 117 | array( |
| | 118 | 'key' => 'sauce', |
| | 119 | 'value' => 'fire' |
| | 120 | ), |
| | 121 | ) |
| | 122 | ) ) ); |
| | 123 | |
| | 124 | foreach ( $other_comment_ids as $cid ) { |
| | 125 | add_comment_meta( $cid, 'sauce', 'fire' ); |
| | 126 | } |
| | 127 | |
| | 128 | $this->assertSame( 6, get_comments( array( |
| | 129 | 'post_id' => $p, |
| | 130 | 'count' => true, |
| | 131 | 'meta_query' => array( |
| | 132 | array( |
| | 133 | 'key' => 'sauce', |
| | 134 | 'value' => 'fire' |
| | 135 | ), |
| | 136 | ) |
| | 137 | ) ) ); |
| | 138 | } |
| | 139 | |
| | 140 | /** |