[wp-trac] [WordPress Trac] #36227: get_categories does not return a valid wp_error

WordPress Trac noreply at wordpress.org
Mon Mar 14 02:03:36 UTC 2016

#36227: get_categories does not return a valid wp_error
 Reporter:  virgodesign   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.5
Component:  Taxonomy      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
Changes (by boonebgorges):

 * version:  4.4.2 =>
 * milestone:  Awaiting Review => 4.5


 Yes, definitely a bug.

 However, I don't think that returning a `WP_Error` object is a wise
 solution. As far as I can see, `get_categories()` has always returned
 nothing but an array. Changing this now is likely to cause compatibility
 problems. And in any case, it's a convenience wrapper for `get_terms()`
 that does nothing much aside from `_make_cat_compat()`; and
 `_make_cat_compat()` only makes sense when you're fetching `category`
 terms, yet when you're fetching `category` terms you won't get a
 `WP_Error`. As such, if you need proper error reporting, and you're not
 fetching `category` terms, just use `get_terms()`.

 See [attachment:36227.diff]. Anyone see a problem with this?

Ticket URL: <https://core.trac.wordpress.org/ticket/36227#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list