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: | dlh | Owned by: | boonebgorges |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.4 |
| Component: | Taxonomy | Version: | 4.4 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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 :) )