Duplicate term insertion allowed after insertion with case differences
|Reported by:||jazbek||Owned by:|
I've discovered a case where duplicate terms can be inserted with wp_insert_term(). Steps to reproduce:
- Insert a term, i.e.
- Insert the same term, but with a different case, i.e.
wp_insert_term('usa', 'country'); // it's ok that this succeeds, because technically it *is* different (case-wise)
- Insert the same term as in step 2. It should fail, but doesn't:
wp_insert_term('usa', 'country'); // succeeds
This is because wp_insert_term() does the following:
- Finds the first term in the db that matches the initial (non-unique) slug for the new term name
- If the name of the found term doesn't match the new term name, then insert continues. In the example above, it's comparing all subsequent 'usa' term names to the first 'USA' term name and determining that it's ok to continue, when it's not because there are other 'usa' terms that it didn't look at.
Change History (7)
comment:3 follow-up: ↓ 4 @kurtpayne — 3 years ago
- Cc kpayne@… added
- Keywords has-patch dev-feedback added
comment:4 in reply to: ↑ 3 ; follow-up: ↓ 5 @DrewAPicture — 3 years ago
Note: See TracTickets for help on using tickets.