[wp-trac] [WordPress Trac] #8087: get_terms problems

WordPress Trac wp-trac at lists.automattic.com
Fri Nov 7 03:55:41 GMT 2008


#8087: get_terms problems
----------------------+-----------------------------------------------------
 Reporter:  filosofo  |       Owner:  anonymous                                                
     Type:  defect    |      Status:  new                                                      
 Priority:  normal    |   Milestone:  2.7                                                      
Component:  General   |     Version:  2.7                                                      
 Severity:  normal    |    Keywords:  has-patch get_terms taxonomy children  _get_term_children
----------------------+-----------------------------------------------------
 There are a couple of problems with {{{get_terms}}}:

  * If the 'child_of' argument is 0 and 'hierarchical' is true (the
 defaults), then terms that have non-zero parent terms are disregarded,
 thanks to the following line:
  {{{$terms = & _get_term_children($child_of, $terms, $taxonomies[0]);}}}

  Because $child_of == 0 and such terms have a non-zero parent,
 {{{_get_term_children}}} excludes them.

  * {{{get_terms}}} allows you to select fields "ids" or "names," in which
 case it currently uses {{{$wpdb->get_col}}} to get an array of those
 values.  However, later {{{get_terms}}} attempts to count child terms (if
 appropriate) and weed out empty terms (if appropriate). But it fails to do
 so in the case when 'fields' is set to 'ids' or 'names'.

 My patch fixes these issues.  It gets term objects from the database no
 matter what, so the results are consistent no matter what fields are
 requested, and {{{_get_term_children}}} is more efficient, because it's
 not retrieving object info for every term.

 I've also made the phpdoc descriptions a little more helpful.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8087>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list