[wp-trac] [WordPress Trac] #14485: Didn't show up children category when created parent and children categories at the same time.

WordPress Trac wp-trac at lists.automattic.com
Sat Dec 11 07:15:00 UTC 2010


#14485: Didn't show up children category when created parent and children
categories at the same time.
--------------------------+-------------------------------------------------
 Reporter:  thealien      |       Owner:             
     Type:  defect (bug)  |      Status:  new        
 Priority:  high          |   Milestone:  3.1        
Component:  Cache         |     Version:  3.0        
 Severity:  normal        |    Keywords:  needs-patch
--------------------------+-------------------------------------------------

Comment(by garyc40):

 Replying to [comment:11 scribu]:
 > The cache key is 'last_changed'. The timestamp is the cache value.

 Yes, sorry I kind of mixed up the terms. Here's the revised edition of my
 explanation:

 Well, here's what I am able to trace out:

 - First, create a term called "Parent". wp_insert_term() will call
 clean_term_cache($term_id, $taxonomy). clean_term_cache() in turn will
 create a new ~~last_changed key based on current timestamp~~ cache: key =>
 'last_changed', value => current timestamp, let's say 1234567890.

 - Second, create a term called "Child", which is a child to "Parent". The
 same process happens. last_changed is ~~still~~ updated with the same
 value 1234567890 (could jump another second, but that rarely happens).

 - Third, let's say you want to get_term_children() of "Parent". It'll call
 _get_term_hierarchy(). _get_term_hierarchy() will check if
 {taxonomy}_children option exists. If it does, return, otherwise, it'll
 call get_terms(). Now here's where the problem lies. If before "Child" or
 "Parent" is created, _get_term_hierarchy() is called, then a cache of
 get_terms before Child or Parent is already there. This time when we call
 get_term_children(), ~~the cache key~~ last_changed value is still the
 same (~~same last_changed~~ 1234567890)~~, so get_terms will return the
 cache value from before "Child" or "Parent" is created~~. Get_terms will
 return the cache at "get_terms::{hashed term queries}::1234567890 which
 was created before "Child" or "Parent" is inserted. Right?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14485#comment:12>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list