[wp-trac] [WordPress Trac] #58116: rest_{$this->taxonomy}_query Cache Problem

WordPress Trac noreply at wordpress.org
Mon Apr 17 03:01:07 UTC 2023


#58116: rest_{$this->taxonomy}_query Cache Problem
--------------------------+------------------------------------
 Reporter:  tnolte        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  6.0
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  rest-api, performance
--------------------------+------------------------------------

Comment (by peterwilsoncc):

 I created a
 [https://gist.github.com/peterwilsoncc/aaa5940052d6ce19bb7a80b2c287e98d
 mini-plugin for testing the ticket] and was able to reproduce:

 1. Activate WP with caching dropin
 1. Create a post using the term "Two Post Types"
 1. Create a '58116 Types' CPT also with the term "Two Post Types"
 1. Ensure cache is clean via wp cli: `wp eval
 "wp_cache_set_terms_last_changed();"`
 1. Visit the rest api endpoint for the taxonomy: `http://wp-dev-
 cached.local/?rest_route=/wp/v2/58116_taxo`
 1. Observe count: `1`
 1. Refresh the rest api endpoint
 1. Observe count: `2`

 On an instance without a persistent cache, the count will remain `1`, as
 expected.

 I agree this isn't a major issue as the argument isn't supported but it's
 certainly something to should look in to. Which is not to say it's
 something that ought to be accounted for.

 As yet, I can't figure out exactly what is happening. I expect it's
 related to using `wp_term_taxonomy->count` (the terms count in the
 database) in the cached data but returning the number of objects returned
 in the initial request. Possibly around the [https://github.com/WordPress
 /wordpress-develop/blob/trunk/src/wp-includes/class-wp-term-
 query.php#L856-L863 code here].

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58116#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list