[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:22:08 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:  3.6.1
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------------
 When calling `get_the_category_by_ID()` with a bad category ID, the
 function internally triggers a PHP notice.  Internally, the function uses
 `get_term()`, which can return `null`. However, the function only checks
 `is_wp_error()` and not null, leading to the following notice:

   Notice: Trying to get property of non-object in /var/www/wordpress/wp-
 includes/category-template.php on line 141

 This bug was originally reported by TechCrunch.

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


More information about the wp-trac mailing list