#22023 closed enhancement (fixed)
Remove UNIQUE for slug in wp_terms
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.1 | Priority: | high |
Severity: | normal | Version: | 2.3 |
Component: | Taxonomy | Keywords: | has-patch 4.1-early |
Focuses: | Cc: |
Description
To set us up for future changes to the taxonomy API, we should remove the UNIQUE key for 'slug' for wp_terms. Said future changes include:
- Splitting shared terms on update (#5809)
- Stop creating shared terms (#21950)
- Forcibly split remaining shared terms
- Merge wp_terms and wp_term_taxonomy (I can dream, right?)
The term_exists() check should prevent duplicate terms from ever being inserted (before, of course, we fix #5809 and #21950). But, this needs unit tests, particularly because there is a case where term_exists() breaks. See #17689, which blocks this ticket.
Attachments (4)
Change History (60)
#12
@
12 years ago
- Keywords reporter-feedback removed
- Milestone changed from 3.5 to Future Release
- Type changed from defect (bug) to enhancement
No unit tests; #17689 not fixed yet. Punting.
#23
@
12 years ago
- Milestone changed from Future Release to 3.7
Fixing #5809 requires this to be fixed to get the ball rolling for http://make.wordpress.org/core/2013/07/28/potential-roadmap-for-taxonomy-meta-and-post-relationships/. #17689 must be fixed first.
#25
@
11 years ago
- Keywords has-patch added; needs-patch removed
There's a patch now. A teeny, tiny one.
#28
@
11 years ago
- Keywords 4.0-early added; 3.9-early removed
Just a hair late for 3.9-early, now ;-)
This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.
11 years ago
This ticket was mentioned in IRC in #wordpress-dev by simonwheatley. View the logs.
11 years ago
#32
@
11 years ago
I'm not clear on the testing requirement here; there are tests newly added by #17689 (test_duplicate_name
) which indirectly exercise term_exists
, but I'm happy to write more direct testing if that's required.
#33
in reply to:
↑ 31
@
11 years ago
Replying to ircbot:
This ticket was mentioned in IRC in #wordpress-dev by simonwheatley. View the logs.
@nacin – "I don't think the current API in any way allows for multiple duplicate term slugs to sneak in the database, except possibly by race condition. which I am concerned about."
I've been thinking about Nacin's concerns above, and AFAIK it's not possible to have a UNIQUE
constraint across the wp_term
and wp_term_taxonomy
tables. If this (race conditions allowing duplicate terms) is a big enough concern to block this ticket, and we need to block the possibility of duplicate terms with a constraint at the database level, then one alternative is to lose the wp_terms
table (as mentioned in the potential taxonomy roadmap) so we can have a UNIQUE
constraint in the restructured wp_term_taxonomy
on taxonomy
and slug
(and name
, perhaps). This is obviously (somewhat understating things) a big change… but we're considering some other structure changes, so may be a good time to get it in? I imagine we'd also want to have time and resource to test both core and existing plugins?
#34
follow-up:
↓ 37
@
11 years ago
Additional tests for term_exists:
- Don't use
rand_str
intest_term_exists_known
ortest_term_exists_unknown
, instead specify a term name (allows for debugging tests more easily if the term name is in DB already) - Check optional
$taxonomy
parameter - Check optional `$parent parameter
- Incidentally check inserting a term with a parent
- Check specifying
$term
as integer other than0
(in this case99999
) - No need to assert the term deletion (we're testing term deletion functionality elsewhere)
This ticket was mentioned in IRC in #wordpress-dev by simonwheatley. View the logs.
11 years ago
This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.
11 years ago
#37
in reply to:
↑ 34
@
11 years ago
Replying to simonwheatley:
Those additional tests look good, and I'm definitely a fan of removing uses of rand_str
(actually seen that cause collisions in rare cases).
Looking forward, let's put together a list of further areas that need testing. No one needs to actually write the tests yet, just pull together a list of what we need to test so we can divvy up work and get started. Thoughts?
#38
@
11 years ago
- Keywords 4.1-early added; 4.0-early removed
- Milestone changed from 4.0 to Future Release
- Priority changed from normal to high
Let's do this in 4.1 early so we can get lots of nice tests in place and testing done.
#40
@
10 years ago
term_exists-tests.02.patch is an exhaustive set of tests for term_exists()
, as well as some tests that show the duplicate-term failure conditions for wp_insert_term()
.
#43
@
10 years ago
The tests committed in r29798 are all passing. As long as all term creation passes through wp_insert_term()
and uses term_exists()
, I'm pretty confident that we're close to being ready to remove the UNIQUE
key.
This ticket was mentioned in IRC in #wordpress-dev by johnbillion. View the logs.
10 years ago
#50
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
I neglected to write the proper upgrade routine for existing installs to remove the UNIQUE index. Reopening.
#52
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Not sure why, but I got 22023.db-error.png.
For the version 3.5 we would need:
slug
on wp_termsterm_exists()
Just checking so we can delivery something on 3.5