[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
Mon Apr 30 21:15:18 UTC 2018


#41035: Don't return if WP_Error object return by wp_insert_term() from foreach()
loop in wp_set_object_terms()
--------------------------+------------------------------
 Reporter:  chandrapatel  |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  4.7
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  administration
--------------------------+------------------------------
Changes (by boonebgorges):

 * keywords:  has-patch dev-feedback close => needs-patch


Comment:

 @pbiron This is a good thought.

 It's worth noting that `WP_Error` objects only allow a single instance of
 an error code. So if multiple terms in the loop return the same error
 code, they'll overwrite the previous error codes. Instead, we might need
 something that intelligently assembles these codes. For example: if more
 than one call to `wp_insert_term()` returns an 'invalid_term_id' error, we
 will need to assemble all the term data into an array, add `add_data()`
 all of those to the `wp_set_object_terms()` error object under the
 'invalid_term_id' slot in the error object. So this will take some
 retooling of the way the `$terms` loop works.

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


More information about the wp-trac mailing list