Changeset 35512
- Timestamp:
- 11/04/2015 09:09:01 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-comment-query.php
r35170 r35512 413 413 $_comments = array(); 414 414 foreach ( $comment_ids as $comment_id ) { 415 if ( $_comment = wp_cache_get( $comment_id, 'comment') ) {415 if ( $_comment = get_comment( $comment_id ) ) { 416 416 $_comments[] = $_comment; 417 417 } -
trunk/tests/phpunit/tests/comment/query.php
r35242 r35512 2148 2148 $this->assertSame( $num_queries, $wpdb->num_queries ); 2149 2149 } 2150 2151 /** 2152 * @ticket 34138 2153 */ 2154 public function test_comment_objects_should_be_filled_from_cache() { 2155 global $wpdb; 2156 2157 $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); 2158 clean_comment_cache( $comments ); 2159 2160 $num_queries = $wpdb->num_queries; 2161 $q = new WP_Comment_Query( array( 2162 'post_id' => $this->post_id, 2163 'no_found_rows' => true, 2164 'update_comment_post_cache' => false, 2165 'update_comment_meta_cache' => false, 2166 ) ); 2167 2168 // 2 queries should have been fired: one for IDs, one to prime comment caches. 2169 $num_queries += 2; 2170 2171 $found = wp_list_pluck( $q->comments, 'comment_ID' ); 2172 $this->assertEqualSets( $comments, $found ); 2173 2174 $this->assertSame( $num_queries, $wpdb->num_queries ); 2175 } 2176 2177 /** 2178 * @ticket 34138 2179 */ 2180 public function test_comment_objects_should_be_fetched_from_database_when_suspend_cache_addition() { 2181 $suspend = wp_suspend_cache_addition(); 2182 wp_suspend_cache_addition( true ); 2183 2184 $c = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); 2185 2186 $q = new WP_Comment_Query( array( 2187 'post_id' => $this->post_id, 2188 ) ); 2189 2190 wp_suspend_cache_addition( $suspend ); 2191 2192 $found = wp_list_pluck( $q->comments, 'comment_ID' ); 2193 $this->assertEqualSets( array( $c ), $found ); 2194 } 2150 2195 }
Note: See TracChangeset
for help on using the changeset viewer.