Make WordPress Core


Ignore:
Timestamp:
07/14/2017 09:24:03 PM (7 years ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

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

    r40340 r41059  
    252252
    253253        // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
    254         $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
     254        $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
     255
     256        // Ignore the $fields argument as the queried result will be the same regardless.
     257        unset( $_args['fields'] );
     258
     259        $key = md5( serialize( $_args ) );
    255260        $last_changed = wp_cache_get_last_changed( 'sites' );
    256261
Note: See TracChangeset for help on using the changeset viewer.