[wp-trac] Re: [WordPress Trac] #8832: function get_categories() doesn't work properly when using child_of and number parameters

WordPress Trac wp-trac at lists.automattic.com
Sat Jan 10 03:56:45 GMT 2009


#8832: function get_categories() doesn't work properly when using child_of and
number parameters
-------------------------------------------------+--------------------------
 Reporter:  jidm                                 |        Owner:  anonymous
     Type:  defect (bug)                         |       Status:  new      
 Priority:  normal                               |    Milestone:  2.7.1    
Component:  General                              |      Version:  2.7      
 Severity:  normal                               |   Resolution:           
 Keywords:  has-patch get_terms number child_of  |  
-------------------------------------------------+--------------------------
Comment (by filosofo):

 To explain a little better:

 What happens currently is that get_terms sets its initial database query
 limit to the "number" parameter, if supplied, and queries the database.
 It then goes through the returned terms and prunes out ones that aren't
 children of X term, or are empty, etc., depending on the other parameters.

 So the number of terms returned by get_terms ultimately does not reflect
 the number of terms matching the parameters limited by the "number"
 parameter; rather, it reflects the number of terms returned by the initial
 query, some of which might not match all the parameters and will therefore
 be pruned out later.

 My patch ignores the "number" parameter for the initial database query in
 those cases in which it's possible that some terms will later be pruned:
 e.g. the ones I mention above: when getting child_of, parent, etc.  It
 then applies it to the array of terms before get_terms returns it.

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


More information about the wp-trac mailing list