[wp-trac] [WordPress Trac] #64038: Cache miss for `WP_Term_Query`
WordPress Trac
noreply at wordpress.org
Wed Sep 24 15:10:59 UTC 2025
#64038: Cache miss for `WP_Term_Query`
--------------------------+-----------------------------
Reporter: Chouby | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
On a WP fresh install (test made with WP 6.8.2).
1. Activate Query Monitor
2. Visit the posts list table
3. Check that Query Monitor report a duplicate query coming from
`WP_Term_Query::get_terms()`:
{{{
SELECT t.term_id
FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt
ON t.term_id = tt.term_id
WHERE tt.taxonomy IN ('category')
ORDER BY t.name ASC
}}}
One call is coming from `wp_dropdown_categories()`
One call is coming from `wp_terms_check_list()`
Both functions are not using the same arguments for the call to
`get_terms()` but result in the same DB query.
In the past, the cache key used to be computed based on arguments passed
to `get_terms()`. It's now [https://github.com/WordPress/wordpress-
develop/blob/6.8.2/src/wp-includes/class-wp-term-query.php#L1174 a
combination of these arguments and the SQL statement]. Maybe using only
the sql statement would be sufficient.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64038>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list