Multisite: Improve caching in `WP_Network_Query` by ignoring the `$fields` argument.
Prior to this change there were two different cache keys used for the same query. That is because regardless of the `$fields` argument, the query response will be the same. This was already fixed for `WP_Site_Query` in [41059]. Props spacedmonkey. Fixes #41347. Built from https://develop.svn.wordpress.org/trunk@41063 git-svn-id: http://core.svn.wordpress.org/trunk@40915 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7820de1a6b
commit
d4607c17b7
|
@ -208,7 +208,12 @@ class WP_Network_Query {
|
||||||
do_action_ref_array( 'pre_get_networks', array( &$this ) );
|
do_action_ref_array( 'pre_get_networks', array( &$this ) );
|
||||||
|
|
||||||
// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
|
// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
|
||||||
$key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
|
$_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
|
||||||
|
|
||||||
|
// Ignore the $fields argument as the queried result will be the same regardless.
|
||||||
|
unset( $_args['fields'] );
|
||||||
|
|
||||||
|
$key = md5( serialize( $_args ) );
|
||||||
$last_changed = wp_cache_get_last_changed( 'networks' );
|
$last_changed = wp_cache_get_last_changed( 'networks' );
|
||||||
|
|
||||||
$cache_key = "get_network_ids:$key:$last_changed";
|
$cache_key = "get_network_ids:$key:$last_changed";
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.9-alpha-41062';
|
$wp_version = '4.9-alpha-41063';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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