Opened 11 years ago
Closed 11 years ago
#34332 closed defect (bug) (fixed)
Change in `get_term()` return value with mismatched term ID and taxonomy
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.4 | Priority: | normal |
| Severity: | normal | Version: | 4.4 |
| Component: | Taxonomy | Keywords: | |
| Focuses: | Cc: |
Description
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.
Change History (2)
Note: See
TracTickets for help on using
tickets.
Ah, thanks for the catch, @dlh. It should be fine to return
nullhere. (I'd prefer to standardize onWP_Error, but I care little enough that preserving the previous behavior is probably preferable :) )