[wp-trac] [WordPress Trac] #28978: wp_send_json_error() should support WP_Error objects
WordPress Trac
noreply at wordpress.org
Tue Jul 22 01:38:13 UTC 2014
#28978: wp_send_json_error() should support WP_Error objects
----------------------------------------+-----------------------------
Reporter: danielbachhuber | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: General | Version:
Severity: normal | Resolution:
Keywords: needs-patch good-first-bug | Focuses:
----------------------------------------+-----------------------------
Comment (by nacin):
I like this. I think it should result in 'code', 'message', and 'data'
keys. We already use 'message' keys in a few places for
wp_send_json_error().
However, WP_Error can have more than one code/message pair. At that point,
what should happen?
1. Should it be only the first code?
2. Should it put the first code/message pair in their own keys, then all
others in an 'additional'-keyed array of code/message pairs?
3. Should it put the first code/message pair in their own keys, then all
of them (including that one) in a 'all' keyed array of all code/message
pairs?
4. Should it be an array of code/message pairs?
The problem with the fourth one is it would result in a different way of
fetching a code/message for a single WP_Error versus a multiple WP_Error.
Unless we make it so a WP_Error is always an array (so you'd always have
to ask for the 0'th value), which seems annoying.
Based on the fact that WP_Error get_error_code() does return the first
code (same for message, etc.), and then there's a separate
get_error_codes() etc., I'd think that point 3 makes the most sense.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28978#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list