Make WordPress Core


Ignore:
Timestamp:
07/30/2017 02:55:17 PM (8 years ago)
Author:
boonebgorges
Message:

Comments: Ignore the 'fields' parameter in the comment query cache.

WP_Comment_Query always queries runs an ID query, and so is unaffected
by the 'fields' parameter. As such, 'fields' can be ignored when building
a cache key for the results of the ID query.

Props spacedmonkey.
Fixes #41348.

File:
1 edited

Legend:

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

    r41162 r41190  
    376376        }
    377377
    378         // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
    379         $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
     378        /*
     379         * Only use the args defined in the query_var_defaults to compute the key,
     380         * but ignore 'fields', which does not affect query results.
     381         */
     382        $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
     383        unset( $_args['fields'] );
     384
     385        $key = md5( serialize( $_args ) );
    380386        $last_changed = wp_cache_get_last_changed( 'comment' );
    381 
    382387
    383388        $cache_key   = "get_comments:$key:$last_changed";
Note: See TracChangeset for help on using the changeset viewer.