[wp-trac] [WordPress Trac] #6593: Tags with custom slugs get recreated on post edit screen

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 4 22:18:03 GMT 2008


#6593: Tags with custom slugs get recreated on post edit screen
----------------------------+-----------------------------------------------
 Reporter:  jhodgdon        |       Owner:  anonymous
     Type:  defect          |      Status:  new      
 Priority:  normal          |   Milestone:  2.5.1    
Component:  Administration  |     Version:  2.5      
 Severity:  normal          |    Keywords:  tags     
----------------------------+-----------------------------------------------
 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.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6593>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list