Tags with custom slugs get recreated on post edit screen
|Reported by:||jhodgdon||Owned by:||ryan|
|Severity:||major||Keywords:||tag custom slug duplicity has-patch|
|Cc:||jhodgdon, count_0, janbrasna|
Here is how to reproduce this bug (the short summary might not be clear about what I am talking about). This applies to 2.5 released version. It was working in earlier 2.5 bleeding, early on, but then got broken by the time of the release, not sure exactly when.
a) Go to the Manage Tags screen, and create a new tag with name "abcdef" and slug "ghi" (without the quotes in all cases). Note that the slug does not match the "sanitized" slug WordPress would create by default.
b) Go to the Write Post screen (edit an existing or create a new post, enter a title and something in the body just to have something to work with).
c) In the Tags section of the Write Post screen, start typing "abc" in the Add Tag box. When "abcdef" appears, click on it, and then click "Add". You'll see it below.
d) Save the post.
e) Return to the Manage Tags screen. You will see that there are now two "abcdef" tags, and the new one has slug "abcdef". The new one is the one that is attached to the post.
The reason for this happening is that when you save the post, WP is taking the tag *names* (which it has carefully saved in a hidden field "tags_input" on the edit screen), and then using is_term to see if they already exist in the DB. is_term just sanitizes the tag name and searches for it as a slug. It doesn't match, so WP creates a brand-new tag.
The reason this is important is that (a) some people override slugs (e.g. non-Euro language users) and (b) if you pick an existing tag from a drop-down list, you should certainly get the tag you picked, not create a new one!!!
The solutions I can imagine:
1) Save the tag slugs rather than tag names in the hidden field, so they will match. This would probably also mean that tag slugs rather than tag names would appear on the post edit screen in the "tags to delete" area, since these delete links and display names are generated from that field.
2) Use something other than is_tag to do the matching.
Any thoughts on which solution to pursue? (1) is probably easier, but (2) might be nicer on the display.
Change History (71)
comment:38 janbrasna — 5 years ago
- Cc janbrasna added
- Component changed from Administration to Taxonomy
- Keywords tag custom slug duplicity needs-patch added; tags has-patch needs-testing removed
- Keywords reporter-feedback added; tag custom slug duplicity needs-patch removed
comment:40 jhodgdon — 5 years ago
- Keywords ag custom slug duplicity needs-patch added; reporter-feedback removed
comment:48 jhodgdon — 5 years ago
- Owner changed from ryan to jhodgdon
- Status changed from reopened to new
comment:50 jhodgdon — 5 years ago
- Keywords has-patch added; needs-patch removed
- Owner changed from jhodgdon to ryan
- Status changed from assigned to new