Make WordPress Core

Opened 7 years ago

Last modified 11 months ago

#40447 new enhancement

Add cache domain to site/network query

Reported by: ocean90's profile ocean90 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-patch needs-refresh close
Focuses: multisite Cc:

Description

A cache domain allows to define a custom cache key to ensure unique results when one of the query filters, like sites_clauses, is used to customize the default query. This is necessary because the default cache key is only computed from the default query variables.

Previously: [18128] for terms and [38117] for comments.

Attachments (1)

40447.patch (3.6 KB) - added by ocean90 7 years ago.

Download all attachments as: .zip

Change History (5)

@ocean90
7 years ago

#1 @ocean90
7 years ago

On second thought, you can use the parse_site_query to register a custom query var like so:

<?php
function add_custom_query_var_to_default_query_vars( $query ) {
        if ( ! empty( $query->query_vars['custom_query_var' ] ) ) {
                $query->query_var_defaults = array_merge( $query->query_var_defaults, [ 'custom_query_var' => '' ] );
        }
}
add_action( 'parse_site_query', __NAMESPACE__ . '\add_custom_query_var_to_default_query_vars' );

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


7 years ago

#3 @flixos90
7 years ago

  • Milestone changed from 4.8 to Future Release

Per Slack: https://wordpress.slack.com/archives/C03BVB47S/p1494269010909400

Let's get back to this ticket as necessary. @spacedmonkey expressed interest in working on this.

#4 @ocean90
11 months ago

  • Keywords needs-refresh close added

@spacedmonkey Do you still have an use case for this? Otherwise I think we can close this as wontfix.
Worth to mention that when an argument is added any existing cache will be invalidated due to the new cache key unless we add some special handling for cache_domain = 'core'.

Note: See TracTickets for help on using tickets.