Opened 3 years ago
Closed 3 years ago
#54074 closed defect (bug) (wontfix)
Slug index not set as unique in databse
Reported by: | odjuret | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.1 |
Component: | Taxonomy | Keywords: | |
Focuses: | docs | Cc: |
Description
Hi,
In the documentation (https://codex.wordpress.org/Database_Description#Table:_wp_terms) it is stated that the wp_terms slug column is unique but is not set as unique in the database. This will allow duplicate values.
Please fix.
Thanks.
Change History (3)
#2
@
3 years ago
- Component changed from General to Taxonomy
- Keywords close added
- Severity changed from critical to normal
Hi there, welcome to WordPress Trac! Thanks for the report.
The UNIQUE
constraint was intentionally removed from the wp_terms
table in [30056] / #22023.
This was the first step in a larger taxonomy overhaul that started in WordPress 4.1:
- Potential roadmap for taxonomy meta and post relationships
- WordPress 4.1: An update on the taxonomy roadmap
- WordPress 4.2: Taxonomy term splitting in 4.2: a developer guide
- WordPress 4.3: Eliminating shared taxonomy terms
- WordPress 4.4: Taxonomy roadmap for 4.4 and beyond
- WordPress 4.4: Taxonomy term metadata proposal
- WordPress 4.4: Taxonomy Roundup
#3
@
3 years ago
- Focuses docs added; performance removed
- Keywords close removed
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
- Version changed from 5.8 to 4.1
As Sergey mentions above, this was an intentional change in WP 4.1 to allow different taxonomies to use the same slug, for example both a names taxonomy and a cities taxonomy could use the slug paris
. The function wp_unique_term_slug()
performs a check to ensure the slug is unique for each taxonomy.
I've updated the codex page to reflect this as it seems it was never updated.
I'm going to close this as wontfix, which is trac's unfriendly term to indicate no cahnge to code is required. I've added the docs focus as a change was required to the codex.
I think its this way as there can be different terms with the same slug. The unique index is the
term_id
and theslug
, not just the slug.