Make WordPress Core


Ignore:
Timestamp:
07/17/2017 08:15:27 PM (9 years ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-network-query.php

    r41005 r41063  
    209209
    210210        // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
    211         $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
     211        $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
     212
     213        // Ignore the $fields argument as the queried result will be the same regardless.
     214        unset( $_args['fields'] );
     215
     216        $key = md5( serialize( $_args ) );
    212217        $last_changed = wp_cache_get_last_changed( 'networks' );
    213218
Note: See TracChangeset for help on using the changeset viewer.