Comments: Use wp_cache_get_multiple in `WP_Comment_Query`.
In the `fill_descendants` method in `WP_Comment_Query`, there is a loop the calls `wp_cache_get` to get `child comments. Instead of getting one key at a time, use `wp_cache_get_multiple` and get all keys at once. Props spacedmonkey, tillkruess, mukesh27. Fixes #57803. Built from https://develop.svn.wordpress.org/trunk@55607 git-svn-id: http://core.svn.wordpress.org/trunk@55119 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f940bc822d
commit
90b94aeddc
|
@ -1030,13 +1030,19 @@ class WP_Comment_Query {
|
||||||
$child_ids = array();
|
$child_ids = array();
|
||||||
$uncached_parent_ids = array();
|
$uncached_parent_ids = array();
|
||||||
$_parent_ids = $levels[ $level ];
|
$_parent_ids = $levels[ $level ];
|
||||||
foreach ( $_parent_ids as $parent_id ) {
|
if ( $_parent_ids ) {
|
||||||
$cache_key = "get_comment_child_ids:$parent_id:$key:$last_changed";
|
$cache_keys = array();
|
||||||
$parent_child_ids = wp_cache_get( $cache_key, 'comment-queries' );
|
foreach ( $_parent_ids as $parent_id ) {
|
||||||
if ( false !== $parent_child_ids ) {
|
$cache_keys[ $parent_id ] = "get_comment_child_ids:$parent_id:$key:$last_changed";
|
||||||
$child_ids = array_merge( $child_ids, $parent_child_ids );
|
}
|
||||||
} else {
|
$cache_data = wp_cache_get_multiple( array_values( $cache_keys ), 'comment-queries' );
|
||||||
$uncached_parent_ids[] = $parent_id;
|
foreach ( $_parent_ids as $parent_id ) {
|
||||||
|
$parent_child_ids = $cache_data[ $cache_keys[ $parent_id ] ];
|
||||||
|
if ( false !== $parent_child_ids ) {
|
||||||
|
$child_ids = array_merge( $child_ids, $parent_child_ids );
|
||||||
|
} else {
|
||||||
|
$uncached_parent_ids[] = $parent_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.3-alpha-55606';
|
$wp_version = '6.3-alpha-55607';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue