[wp-trac] [WordPress Trac] #9323: Legacy get_category_link function call in get_term_link function should probably use $term->ID or be removed

WordPress Trac wp-trac at lists.automattic.com
Thu Mar 12 15:59:17 GMT 2009


#9323: Legacy get_category_link function call in get_term_link function should
probably use $term->ID or be removed
--------------------------+-------------------------------------------------
 Reporter:  ev3rywh3re    |       Owner:  ryan                                               
     Type:  defect (bug)  |      Status:  new                                                
 Priority:  normal        |   Milestone:  2.8                                                
Component:  Taxonomy      |     Version:  2.8                                                
 Severity:  normal        |    Keywords:  get_the_term_list, get_term_link, get_category_link
--------------------------+-------------------------------------------------
 To replicate this bug in a loop somehow use something like:

 {{{
 $cats = get_the_term_list( $post->ID, 'category', '', '|', '' );
 }}}

 In this case get_the_term_list puts together a term object but then when
 it calls get_term_link the get_term_link function tries to pass the term
 object to get_category_link which is really asking for a category ID.

 The culprit is wp-includes/taxonomy.php lines 2122-2123

 {{{
         if ( $taxonomy == 'category' )
                 return get_category_link($term);
 }}}

 For testing I removed that line and it worked when using get_the_term_list
 from the example. I also modified $term to pass $term->ID instead and that
 worked as well. There's no patch because it has multiple solutions and I
 don't think I have enough test cases to make a proper judgment call for a
 solution.

 I know category functions need to be modified to use the taxonomy
 functions more elegantly. I also know this is considered an internal
 function and get_the_category_list should be used instead, but I
 mistakenly thought get_the_term_list was pretty cool looking.

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


More information about the wp-trac mailing list