mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-03 04:04:35 +00:00
Cache API: Improve cache key generation in WP_Comment_Query.
Discard the parameters `update_comment_meta_cache` and `update_comment_post_cache` when generating the cache key as neither have an effect on the database query generated. Props uday17035, spacedmonkey. Fixes #55460. git-svn-id: https://develop.svn.wordpress.org/trunk@53169 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4941,4 +4941,31 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
|
||||
return array( get_comment( $c ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 55460
|
||||
*/
|
||||
public function test_comment_cache_key_should_ignore_unset_params() {
|
||||
$p = self::factory()->post->create();
|
||||
$c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
|
||||
|
||||
$_args = array(
|
||||
'post_id' => $p,
|
||||
'fields' => 'ids',
|
||||
'update_comment_meta_cache' => true,
|
||||
'update_comment_post_cache' => false,
|
||||
);
|
||||
|
||||
$q1 = new WP_Comment_Query();
|
||||
$q1->query( $_args );
|
||||
|
||||
$num_queries_all_args = get_num_queries();
|
||||
|
||||
// Ignore 'fields', 'update_comment_meta_cache', 'update_comment_post_cache'.
|
||||
unset( $_args['fields'], $_args['update_comment_meta_cache'], $_args['update_comment_post_cache'] );
|
||||
$q2 = new WP_Comment_Query();
|
||||
$q2->query( $_args );
|
||||
|
||||
$this->assertSame( $num_queries_all_args, get_num_queries() );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user