[wp-trac] [WordPress Trac] #64038: Cache miss for `WP_Term_Query`

WordPress Trac noreply at wordpress.org
Fri Sep 26 01:46:51 UTC 2025


#64038: Cache miss for `WP_Term_Query`
-------------------------------+-----------------------------
 Reporter:  Chouby             |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Future Release
Component:  Taxonomy           |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:  performance
-------------------------------+-----------------------------
Changes (by westonruter):

 * keywords:   => reporter-feedback
 * milestone:  Awaiting Review => Future Release


Comment:

 I added some logging after the `$key` is generated:

 {{{#!php
 <?php
 do_action( 'qm/debug', compact( 'key', 'cache_args', 'sql' ) );
 }}}

 This is the difference between the logging for the duplicate queries:

 {{{#!diff
 --- /tmp/first.txt      2025-09-25 18:29:50
 +++ /tmp/second.txt     2025-09-25 18:29:58
 @@ -1,6 +1,6 @@
  Array
  (
 -    [key] => 7e29979b0d775b6021a8f36e13aae8e5
 +    [key] => 5a24f652b8a6b799e1e6d7d7b6afceca
      [cache_args] => Array
          (
              [taxonomy] => Array
 @@ -42,12 +42,12 @@
                  (
                  )

 -            [hierarchical] =>
 +            [hierarchical] => 1
              [search] =>
              [name__like] =>
              [description__like] =>
              [pad_counts] =>
 -            [get] => all
 +            [get] =>
              [child_of] => 0
              [parent] =>
              [childless] =>
 }}}

 My concern is that perhaps a different post-processed query result is
 being cached. However, by adding other logging when the cache is set, this
 doesn't seem to be the case:

 {{{#!diff
 --- /tmp/first.txt      2025-09-25 18:38:48
 +++ /tmp/second.txt     2025-09-25 18:38:58
 @@ -1,6 +1,6 @@
  Array
  (
 -    [cache_key] => get_terms:7e29979b0d775b6021a8f36e13aae8e5
 +    [cache_key] => get_terms:5a24f652b8a6b799e1e6d7d7b6afceca
      [term_cache] => Array
          (
              [0] => 1
 }}}

 The cache key was most recently modified to remove a redundant parameter
 component in r59028, and previously in 55083.

 Even back r37572 it was:

 {{{#!php
 <?php
 $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $defaults
 ) ) ) . serialize( $taxonomies ) . $query );
 }}}

 @Chouby When was the cache key just the SQL and not the args?

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


More information about the wp-trac mailing list