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

WordPress Trac noreply at wordpress.org
Thu Oct 3 15:06:03 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:  Awaiting Review
Component:  Taxonomy               |     Version:  2.3
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |
-----------------------------------+------------------------------
Changes (by nacin):

 * keywords:  has-patch dev-feedback => has-patch 2nd-opinion
 * milestone:  3.7 => Awaiting Review


Comment:

 [attachment:25429.3.diff] is solid. However, this will cause `echo
 get_the_category_by_ID( $nonexistent_id )` to go from a notice to a fatal
 error. So this is definitely too late for 3.7, and possibly shouldn't
 occur at all. Returning `''` or `null` might be better, given this is a
 function designed for presentation.

 I feel like deprecating the oddly named get_the_category_by_ID() could
 also be a possible action here.

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


More information about the wp-trac mailing list