[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
Thu Jul 3 09:19:29 UTC 2025


#39926: wp_get_object_terms should return WP_Error on wrong fields argument or use
a sane default
------------------------------------+------------------------------
 Reporter:  BjornW                  |       Owner:  (none)
     Type:  defect (bug)            |      Status:  closed
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Taxonomy                |     Version:
 Severity:  normal                  |  Resolution:  wontfix
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+------------------------------
Changes (by callumbw95):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 Hi All,

 I have just taken a look at this ticket now, and whilst returning a
 `WP_Error` for an invalid `$fields` argument is logical, making this
 change now would introduce a significant backward-compatibility break.

 The `wp_get_object_terms()` function has consistently returned an empty
 array in this scenario for many major WordPress releases. Countless
 plugins and themes rely on the function's return type always being an
 array. Changing it to a `WP_Error` object would likely cause fatal errors
 on sites where the code is not built to handle an object return.

 The potential to break existing sites is too high to justify this change.
 Therefore, I am closing this ticket as `wontfix`. However please feel free
 to reopen this ticket if you wish to continue the discussion further.

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


More information about the wp-trac mailing list