[wp-trac] [WordPress Trac] #50225: get_edit_term_link can technically accept also WP_Term and object for $term_id

WordPress Trac noreply at wordpress.org
Fri Nov 26 22:53:28 UTC 2021


#50225: get_edit_term_link can technically accept also WP_Term and object for
$term_id
-------------------------------------------------+-------------------------
 Reporter:  david.binda                          |       Owner:  audrasjb
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  high                                 |   Milestone:  5.9
Component:  Taxonomy                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-dev-  |     Focuses:
  note needs-docs commit                         |  performance
-------------------------------------------------+-------------------------
Changes (by dlh):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 I'm sorry to reopen this again, but [52255] retrieves the
 `$term->taxonomy` property before the type safety check on `$term`:

 {{{
 $taxonomy = $term->taxonomy;

 if ( empty( $term ) || is_wp_error( $term ) ) {
         return false;
 }
 }}}

 Wouldn't it be preferable to reverse these statements?

 Also, the documentation for `$taxonomy`:

 `Defaults to 'category' if term ID or non WP_Term object is passed.`

 seems to no longer be accurate, since `$taxonomy` is now passed as-is to
 `get_term()` regardless of the type of `$term`.

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


More information about the wp-trac mailing list