[wp-trac] [WordPress Trac] #58255: wp_send_json_error should respect error state passed in WP_Error.

WordPress Trac noreply at wordpress.org
Mon Jun 19 11:03:55 UTC 2023


#58255: wp_send_json_error should respect error state passed in WP_Error.
--------------------------------------+------------------------------
 Reporter:  spacedmonkey              |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Administration            |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  good-first-bug has-patch  |     Focuses:
--------------------------------------+------------------------------

Comment (by spacedmonkey):

 Replying to [comment:5 danielbachhuber]:
 > I'm not opposed to it, but I'm not sure how much value it provides.
 >
 > One backwards compat concern: If someone is already passing a `WP_Error`
 object into `wp_send_json_error()`, this would change the behavior.
 >
 > Additionally, 'status' is a magical property of REST API errors. If we
 were to introduce this new behavior, we may want to formalize that in some
 way.

 I am not sure what the best course is here. I think the change of
 behaviour is a good thing, as the correct error code is sent. I don't see
 why changing this error state would be a problem.

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


More information about the wp-trac mailing list