[wp-trac] [WordPress Trac] #25429: `get_the_category_by_ID` triggers PHP notice on non-existent category

WordPress Trac noreply at wordpress.org
Fri Sep 27 23:55:18 UTC 2013


#25429: `get_the_category_by_ID` triggers PHP notice on non-existent category
--------------------------+------------------
 Reporter:  ericmann      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.7
Component:  Taxonomy      |     Version:  2.3
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------
Changes (by SergeyBiryukov):

 * version:  3.6.1 => 2.3
 * milestone:  Awaiting Review => 3.7


Comment:

 According to the inline docs, `get_the_category_by_ID()` returns either a
 string or a `WP_Error` object, so returning null might break existing
 code.

 [attachment:25429.2.diff] makes sure `get_category()` returns `WP_Error`
 if `get_term()` returns null, and clarifies the return value. The changes
 in `get_the_category_by_ID()` are not needed in that case.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25429#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list