[wp-trac] [WordPress Trac] #62031: Term cache is not properly cleaned when using persistent object caching

WordPress Trac noreply at wordpress.org
Tue Sep 10 19:32:49 UTC 2024


#62031: Term cache is not properly cleaned when using persistent object caching
--------------------------+-----------------------------
 Reporter:  Dekadinious   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  6.6.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When persistent object caching is used, the term cache is not properly
 cleaned when inserting a term as a child under another term using
 wp_insert_term. I am not sure if it happens when inserting terms in
 general. This has created quite a problem for our site which imports terms
 from another system. Many duplicates are made on each import.

 Let's say you have a parent term with ID 34758. The import process inserts
 a child term by doing something like


 {{{
 wp_insert_term( 'Child term', 'taxonomy', array( 'parent' => 34758) );
 }}}

 The wp_insert_term documentation states "The term cache is cleaned.".

 However, if we do:

 {{{
 get_terms(
     array(
         'taxonomy'   => 'taxonomy',
         'hide_empty' => false,
         'parent'     => 34758,
     )
 );
 }}}

 we get an empty array. Doing these two over and over again always
 successfully inserts a child term, but always returns an empty array. The
 child terms only appear after flushing the entire object cache.

 I would expect wp_insert_term to flush the cache in such a way that
 get_terms returns the newly inserted child even when using persistent
 object caching. Otherwise one will not be able to group imported objects
 under the same child term because a new one will always be created since
 it can't find the newly created existing one that both objects should be
 connected to.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62031>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list