[wp-trac] [WordPress Trac] #39926: wp_get_object_terms should return WP_Error on wrong fields argument or use a sane default

WordPress Trac noreply at wordpress.org
Tue Feb 21 22:28:21 UTC 2017


#39926: wp_get_object_terms should return WP_Error on wrong fields argument or use
a sane default
--------------------------+------------------------------
 Reporter:  BjornW        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by dd32):

 I'm actually OK with the SQL error being generated in this case - it's a
 developer error which they'll otherwise get no notification of, garbage in
 = garbage out type thing.

 The alternative here would be for the `default` in the switch statement to
 simply `return array();` but that would then hide the source of the error
 and cause more debugging.
 Having it default to `all` doesn't seem that great at first, mostly
 because it's not what the developer has requested - and they'd get no
 feedback about why it's happening, however, they'd get back a object which
 should be pretty obviously not what they requested in that scenario, and
 should highlight to the developer they've passed something invalid.

 If [attachment:fix-39926.diff] is the route taken, the `default:` should
 be added to the `all` branch of the `switch` (not duplicating it by
 itself), and it could probably set `$args['fields']` to `'all'` for later
 use?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39926#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list