Changeset 53169
- Timestamp:
- 04/13/2022 02:55:34 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-comment-query.php
r52977 r53169 445 445 /* 446 446 * Only use the args defined in the query_var_defaults to compute the key, 447 * but ignore 'fields', which does not affect query results.447 * but ignore 'fields', 'update_comment_meta_cache', 'update_comment_post_cache' which does not affect query results. 448 448 */ 449 449 $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ); 450 unset( $_args['fields'] );450 unset( $_args['fields'], $_args['update_comment_meta_cache'], $_args['update_comment_post_cache'] ); 451 451 452 452 $key = md5( serialize( $_args ) ); -
trunk/tests/phpunit/tests/comment/query.php
r52010 r53169 4942 4942 return array( get_comment( $c ) ); 4943 4943 } 4944 4945 /** 4946 * @ticket 55460 4947 */ 4948 public function test_comment_cache_key_should_ignore_unset_params() { 4949 $p = self::factory()->post->create(); 4950 $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) ); 4951 4952 $_args = array( 4953 'post_id' => $p, 4954 'fields' => 'ids', 4955 'update_comment_meta_cache' => true, 4956 'update_comment_post_cache' => false, 4957 ); 4958 4959 $q1 = new WP_Comment_Query(); 4960 $q1->query( $_args ); 4961 4962 $num_queries_all_args = get_num_queries(); 4963 4964 // Ignore 'fields', 'update_comment_meta_cache', 'update_comment_post_cache'. 4965 unset( $_args['fields'], $_args['update_comment_meta_cache'], $_args['update_comment_post_cache'] ); 4966 $q2 = new WP_Comment_Query(); 4967 $q2->query( $_args ); 4968 4969 $this->assertSame( $num_queries_all_args, get_num_queries() ); 4970 } 4944 4971 }
Note: See TracChangeset
for help on using the changeset viewer.