[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:00:41 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):

 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, let's say
 1234567890.

 - Second, create a term called "Child", which is a child to "Parent". The
 same process happens. last_changed is still 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 is still the same (same last_changed),
 so get_terms will return the cache value from before "Child" or "Parent"
 is created. Right?

 If you want to test, see #14399, the code snippet in the ticket
 description, only change get_child_term() to get_term_children() with the
 same arguments.

 Quite twisted and confusing indeed.

 I'll include a revised patch asap.

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


More information about the wp-trac mailing list