Opened 7 years ago
Closed 7 years ago
#41197 closed enhancement (fixed)
Improved caching on WP_Site_Query
Reported by: | spacedmonkey | Owned by: | flixos90 |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | Networks and Sites | Keywords: | has-patch has-unit-tests |
Focuses: | multisite | Cc: |
Description
In WP_Site_Query, queries are cached as a list of site ids. The key cache is generated using the query args. But even through the values in the cache are the same, if you query by 'fields' => 'all'
and 'fields' => 'ids'
, two caches are generated. By unsetting the 'fields'
arg before generating the cache key, both queries will use the same cache.
Attachments (2)
Change History (8)
#3
@
7 years ago
- Milestone changed from Awaiting Review to 4.9
- Owner set to spacedmonkey
- Status changed from new to assigned
Per discussion with @spacedmonkey, he'll take care of what still needs to happen here.
Note: See
TracTickets for help on using
tickets.
41197.diff looks good, there are just a few things that can be improved:
$fields
argument can always be unset, even if$count
is true, as that parameter will already distinguish in the cache key between whether to store a count or not.$fields
set toall
, the other with$fields
set toids
.$wpdb->num_queries
should match.$count
set totrue
in both queries.$wpdb->num_queries
should match.$fields
value!), but one time with the$count
argument as true.$wpdb->num_queries
should differ.