[wp-trac] [WordPress Trac] #34332: Change in `get_term()` return value with mismatched term ID and taxonomy

WordPress Trac noreply at wordpress.org
Fri Oct 16 20:53:27 UTC 2015


#34332: Change in `get_term()` return value with mismatched term ID and taxonomy
--------------------------+-----------------------------
 Reporter:  dlh           |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Before r34997, calling `get_term()` with a term ID and a taxonomy that
 were valid but mismatched would return `null`. That pairing now returns a
 `WP_Error` after `get_term()` calls `_split_shared_term()` to no effect.

 To demonstrate, this test starts failing after r34997:

 {{{
 function test_get_term_return_value() {
     $term_id = $this->factory->term->create( array( 'taxonomy' =>
 'post_tag' ) );
     $this->assertNull( get_term( $term_id, 'category' ) );
 }
 }}}

 `get_term()` already returned an error in some situations, so adding one
 here might not be worth worrying about. In my case, I happened to have a
 unit test that was not looking for a `WP_Error` and broke.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34332>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list