Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#31617 closed defect (bug) (duplicate)

Adding new term is not checking uniqueness of slug

Reported by: gjaworek's profile gjaworek Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1
Component: Taxonomy Keywords:
Focuses: Cc:

Description

I'm able to register several NEW terms in various taxonomies with the same slug.
When I try to edit it by quick edit, or full edit validation works correctly, this is only when registering new terms in different taxonomies with the same slug.
When try to register new term with slug which is already existing in the same taxonomy, validation also works correctly.

Steps to reproduce:

  1. Open two Add new term forms for different taxonomy
  2. Add term in first taxonomy
  3. Add the same term in second taxonomy
  4. Notice, both are created with the same slug without any prompt
  5. Pick one of them and in quick edit change slug to different
  6. Try to go back with slug name to the same as in other taxonomy - proper prompt that name is already in use will be shown
  7. Notice that at point 7 you are not able to create duplicated slug name, but on point 3 you achieved this in other way
  8. Just for fun, you can add 3th term with same slug in 3th taxonomy :)

Change History (5)

#1 @boonebgorges
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Thanks for the report, gjaworek.

The ability to create terms with duplicate slugs in different taxonomies is a feature (introduced in 4.1), not a bug. See #21950, #5809. In 4.1, there was indeed a bug that prevented terms from properly being updated to have existing slugs. This will be fixed for 4.2 [30985] and was also fixed for 4.1.1 [31378]. See #30780.

#2 follow-up: @gjaworek
10 years ago

Thank you for a quick reply, I understand that it could be a feature, but I didn't seen it on release notes. I was so used to fact that term slugs are quique, that I threated is as bug automatically. I will need to adjust my applications now. As I understand from linked tickets, this also will be possible to set the same slug for different taxonomies when editing old term, notonly adding new one? In 4.1 it is still not working perfectly.

#3 in reply to: ↑ 2 @boonebgorges
10 years ago

Replying to gjaworek:

Thank you for a quick reply, I understand that it could be a feature, but I didn't seen it on release notes. I was so used to fact that term slugs are quique, that I threated is as bug automatically. I will need to adjust my applications now. As I understand from linked tickets, this also will be possible to set the same slug for different taxonomies when editing old term, notonly adding new one? In 4.1 it is still not working perfectly.

You'll only need to adjust it in your applications if you are using custom SQL queries to fetch terms, and depending on the uniqueness of slugs to do so. Everywhere in the WP API (see functions like get_term()), a $taxonomy parameter is required, which means that the ability to have slugs duplicated in different taxonomies should not cause any issues. There will be some related changes in WP 4.2 that *might* affect your custom applications - see https://make.wordpress.org/core/2015/02/16/taxonomy-term-splitting-in-4-2-a-developer-guide/ for more information.

As noted in my previous comment, the ability to set the same slug for different taxonomies when editing is fixed in 4.1.1, which has already been released, as well as 4.2.

#4 @gjaworek
10 years ago

Ok thank you, I will handle this, I have some custom complicated queries without API as well as plugins, but I can fix all of it now, when I know this is new feature :) From perspective, it was really missing, feature, so I'm glad that don't need to prefix terms anymore :D

#5 @boonebgorges
10 years ago

From perspective, it was really missing, feature, so I'm glad that don't need to prefix terms anymore :D

A big +1 from me :) Thanks again for the report.

Note: See TracTickets for help on using tickets.