[wp-trac] [WordPress Trac] #47313: Handle error in wp_insert_term if writing to the term_taxonomy table fails

WordPress Trac noreply at wordpress.org
Fri May 17 21:31:00 UTC 2019


#47313: Handle error in wp_insert_term if writing to the term_taxonomy table fails
--------------------------+-----------------------------
 Reporter:  mbabker       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I ran into a bit of an edge case scenario where a custom WP-CLI command
 which was importing data from an incorrectly encoded CSV file would
 eventually trigger a call to `wp_insert_term()` inside another plugin and
 the insert query for the term_taxonomy table would not be executed as
 `wpdb::strip_invalid_text()` would rip out the invalid characters.  Before
 isolating the file's encoding as the problem, the code that was calling
 `wp_insert_term()` was assuming a success state since an error wasn't
 being returned and its call to `get_term()` would end up not fetching the
 correct WP_Term object and start spitting out PHP "Trying to get property
 of non-object" notices as a result.

 The upcoming patch adds a check inside `wp_insert_term()` to check for a
 false return from `wpdb::insert()` and will return a WP_Error if so.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47313>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list