#47313 closed defect (bug) (fixed)
Handle error in wp_insert_term if writing to the term_taxonomy table fails
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.3 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Taxonomy | Keywords: | has-patch |
| Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (5)
#1
@
7 years ago
- Component changed from General to Taxonomy
- Keywords has-patch added
- Milestone changed from Awaiting Review to 5.3
#2
@
7 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
#3
follow-up:
↓ 4
@
7 years ago
The error message could probably be clarified a bit. How about Could not insert term taxonomy relationship into the database..
#4
in reply to:
↑ 3
@
7 years ago
Replying to johnbillion:
The error message could probably be clarified a bit. How about
Could not insert term taxonomy relationship into the database..
I've considered this, but thought it might be a bit more confusing, since the message is about the term_taxonomy table, not term_relationships.
"Term taxonomy" wording is used in quite a few DocBlocks, so the message seems fine as is to me.
In 45362: