[wp-trac] Re: [WordPress Trac] #8150: walker class special case

WordPress Trac wp-trac at lists.automattic.com
Tue Nov 11 20:45:31 GMT 2008


#8150: walker class special case
--------------------------------------------------+-------------------------
 Reporter:  hailin                                |        Owner:  anonymous
     Type:  defect                                |       Status:  new      
 Priority:  normal                                |    Milestone:  2.7      
Component:  General                               |      Version:  2.7      
 Severity:  normal                                |   Resolution:           
 Keywords:  has-patch, tested, reporter-feedback  |  
--------------------------------------------------+-------------------------
Comment (by hailin):

 The issues is that with calls such as:

 wp_list_categories('use_desc_for_title=1&child_of=400052&title_li=')

 It will produce array $elements (categories), and there is not a single
 element whose parent=0 since they are children of 400052.

 Then it will be handled by:

                 /*
                  * when none of the elements is top level
                  * assume the first one must be root of the sub elements
                  */
                 if ( empty($top_level_elements) )
                       ....

 Because $elements is an associative array, the key may  not begin with 0.
 I've observed a bug on a particular blog, in which case the first
 element's key is
 2.  That caused the $root= $elements[0] to be NULL since the key 0 does
 not exist.

 As a result, $top_level_elements are empty, and then every element is
 displayed as orphans. The correct results would be nested structure.

 With this fix, they are displayed correctly. It's tested in both positive
 and negative cases.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8150#comment:3>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list