[wp-trac] [WordPress Trac] #50344: Update @return docs for get_tags() to reflect that WP_Error is a possible return value

WordPress Trac noreply at wordpress.org
Mon Jun 8 22:33:00 UTC 2020


#50344: Update @return docs for get_tags() to reflect that WP_Error is a possible
return value
--------------------------+-----------------------------
 Reporter:  coffee2code   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  low           |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:
 Severity:  minor         |   Keywords:  has-patch
  Focuses:  docs          |
--------------------------+-----------------------------
 `get_tags()`, by virtue of its call to `get_terms()`, has the potential to
 return a `WP_Error` object (if a specified taxonomy does not exist).

 Unlike the similar `get_categories()`, `get_tags()` does not check for an
 error and return an empty array if there is one, so a `WP_Error` object
 can be returned by `get_tags()`.

 Patch attached.

 Quick demonstration of return value:
 {{{
 $ wp eval "var_dump( get_tags( [ 'taxonomy' => 'xyz' ] ) );"
 object(WP_Error)#1621 (2) {
   ["errors"]=>
   array(1) {
     ["invalid_taxonomy"]=>
     array(1) {
       [0]=>
       string(17) "Invalid taxonomy."
     }
   }
   ["error_data"]=>
   array(0) {
   }
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50344>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list