Opened 9 years ago
Closed 9 years ago
#41197 closed enhancement (fixed)
Improved caching on WP_Site_Query
| Reported by: | spacedmonkey | Owned by: | flixos90 |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.9 |
| Component: | Networks and Sites | Version: | 4.6 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: | multisite |
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)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
41197.diff looks good, there are just a few things that can be improved:
$fieldsargument can always be unset, even if$countis true, as that parameter will already distinguish in the cache key between whether to store a count or not.$fieldsset toall, the other with$fieldsset toids.$wpdb->num_queriesshould match.$countset totruein both queries.$wpdb->num_queriesshould match.$fieldsvalue!), but one time with the$countargument as true.$wpdb->num_queriesshould differ.