[wp-trac] [WordPress Trac] #27123: get_categories returning duplicate child categories in 3.9

WordPress Trac noreply at wordpress.org
Thu Feb 20 01:48:08 UTC 2014


#27123: get_categories returning duplicate child categories in 3.9
--------------------------+------------------------------
 Reporter:  BStofko       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by BStofko):

 I have tracked this down to the function _get_term_children in wp-
 includes/taxonomy.php.

 A new section of code has been added, which essentially duplicates the
 work of an old section of code that is still there. I'm not sure what is
 the reason for the new code, but it seems that one or the other should be
 removed.


 {{{
 /* This (new) block adds the child terms to $term_list */
 if ( $term->term_id == $term_id ) {
         if ( isset( $has_children[$term_id] ) ) {
                 $current_id = $term_id;
                 while ( $current_id > 0 ) {
                         foreach ( $has_children[$current_id] as $t_id ) {
                                 if ( $use_id ) {
                                         $term_list[] = $t_id;
                                 } else {
                                         $term_list[] = get_term( $t_id,
 $taxonomy );
                                 }
                         }
                         $current_id = isset( $has_children[$t_id] ) ?
 $t_id : 0;
                 }
         }
         continue;
 }

 /* This (old) block adds the child terms to $term_list again! */
 if ( $term->parent == $term_id ) {
         if ( $use_id )
                 $term_list[] = $term->term_id;
         else
                 $term_list[] = $term;

         if ( !isset($has_children[$term->term_id]) )
                 continue;

         if ( $children = _get_term_children($term->term_id, $terms,
 $taxonomy) )
                 $term_list = array_merge($term_list, $children);
 }
 }}}

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


More information about the wp-trac mailing list