[wp-trac] [WordPress Trac] #33281: get_term_by() not returning false if ID does not exist

WordPress Trac noreply at wordpress.org
Mon Sep 14 19:40:47 UTC 2015


#33281: get_term_by() not returning false if ID does not exist
------------------------------+------------------
 Reporter:  charlestonsw      |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  4.4
Component:  Taxonomy          |     Version:  2.3
 Severity:  normal            |  Resolution:
 Keywords:  needs-unit-tests  |     Focuses:
------------------------------+------------------
Changes (by boonebgorges):

 * keywords:  close => needs-unit-tests
 * milestone:  Awaiting Review => 4.4


Comment:

 In the past, we've made a conscious decision that `get_term_by()` should
 return only `false` on failure, so that it could be used like this: `if (
 $term = get_term_by() )` For example, [17526] made it impossible to return
 a `WP_Error` object. See #16464.

 It's true that returning `null` vs `false` is not precisely the same thing
 as the above, but I think it's in the same spirit. And it's very difficult
 to come up with a reasonable situation in which `null` would be
 distinguished from `false` in the context of `get_term_by()`. Let's switch
 it.

 Can we get a unit test that demonstrates the issue, please?

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


More information about the wp-trac mailing list