From af50e8eb2c78e5f05b20ac4eecbe578b2c85cd04 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 14 Jul 2017 21:25:44 +0000 Subject: [PATCH] Multisite: Improve caching in `WP_Site_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. Props spacedmonkey. Fixes #41197. Built from https://develop.svn.wordpress.org/trunk@41059 git-svn-id: http://core.svn.wordpress.org/trunk@40909 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-site-query.php | 7 ++++++- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-site-query.php b/wp-includes/class-wp-site-query.php index b711422479..774f83ea18 100644 --- a/wp-includes/class-wp-site-query.php +++ b/wp-includes/class-wp-site-query.php @@ -251,7 +251,12 @@ class WP_Site_Query { do_action_ref_array( 'pre_get_sites', array( &$this ) ); // $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( 'sites' ); $cache_key = "get_sites:$key:$last_changed"; diff --git a/wp-includes/version.php b/wp-includes/version.php index 570416b763..8a5376bb44 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41058'; +$wp_version = '4.9-alpha-41059'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.