[wp-trac] [WordPress Trac] #41035: Don't return if WP_Error object return by wp_insert_term() from foreach() loop in wp_set_object_terms()
WordPress Trac
noreply at wordpress.org
Sat Jul 1 14:00:24 UTC 2017
#41035: Don't return if WP_Error object return by wp_insert_term() from foreach()
loop in wp_set_object_terms()
------------------------------------------+------------------------------
Reporter: chandrapatel | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch dev-feedback close | Focuses: administration
------------------------------------------+------------------------------
Changes (by boonebgorges):
* keywords: has-patch dev-feedback => has-patch dev-feedback close
Comment:
Hi @chandrapatel - Thanks for the detailed description of the issue. I
agree that the error handling in `wp_set_object_terms()` is less than
ideal. The function should either: (a) skip failures but process all other
terms, or (b) bail from the entire function if there are any errors.
Currently it does a mix of the two.
I think that it's important to retain the `WP_Error`. Silently skipping
failed terms, without providing feedback to the developer, makes it
potentially difficult to debug problems. This is especially true since we
*currently* return an error object; plugins may be expecting it.
We currently don't have a great way of handling return values in mixed-
success situations. We can only return one thing: in this case, it's
either an array of `$tt_ids` or a `WP_Error` object. If we allowed the
function to process partially, it's not clear to me how we would provide
this information to developers. I think this is probably the main reason
why we ought to keep something like the current (imperfect) behavior. Do
you have ideas about how this error reporting can be improved without
losing important feedback for developers?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41035#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list