Legacy get_category_link function call in get_term_link function should probably use $term->ID or be removed
|Reported by:||ev3rywh3re||Owned by:||ryan|
|Severity:||normal||Keywords:||has-patch tested commit|
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.
Change History (20)
comment:3 follow-up: ↓ 4 Denis-de-Bernardy — 5 years ago
- Keywords needs-patch added; has-patch removed
- Keywords needs-patch added; has-patch tested commit removed
- Keywords has-patch commit added; get_the_term_list get_term_link get_category_link needs-patch removed