Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#3683 closed defect (bug) (fixed)

It is possible to create multiple categories with the same name and same slug

Reported by: johnbillion's profile johnbillion Owned by: rob1n's profile rob1n
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.1
Component: Administration Keywords: dev-feedback 2nd-opinion
Focuses: Cc:

Description

This is a trivial one, I know.

It is possible to create multiple categories with the same name and/or same slug, and doing so breaks all concerned categories.

To recreate:

  1. Go to Manage -> Categories in the admin panel.
  1. Create a new category.
  1. Create another category with the same name and/or same slug.
  1. Place some posts into these categories (so they show up on the blog) and then attempt to browse one of the categories via the blog. A 404 Not Found error is returned on all categories concerned.

=================

Desired Behaviour:

Either the user is alerted that they are attempting to create a duplicate category, or the duplicate category is created with a numerical suffix on the slug (eg. articles-2) much the same as is done with multiple blog posts that have the same titles.

IMO the first option would be preferable.

Change History (16)

#1 @johnbillion
17 years ago

  • Severity changed from trivial to minor

#2 @foolswisdom
17 years ago

  • Milestone set to 2.1.1
  • Priority changed from lowest to high
  • Severity changed from minor to major

johnbillion, thank you for the excellent bug reports!

Raising severity because not supposed to be able to create duplicate categories.

#3 @Nazgul
17 years ago

  • Milestone changed from 2.1.1 to 2.1.2

2.1.1 is out, so bumping the milestone to 2.1.2.

#4 @johnbillion
17 years ago

Anyone have an opinion on the desired behaviour in this situation? It might spur someone on to write a patch if a decision about the desired behaviour is made. (I'd do it myself, alas I'm not familiar enough yet with WordPress.)

#5 @rob1n
17 years ago

  • Milestone changed from 2.1.3 to 2.2
  • Owner changed from anonymous to rob1n
  • Status changed from new to assigned

I'd say this should be fixed. It's expected behavior, and things go haywire if two categories have the same slugs.

But then again, why would you create categories with the same name and or slug? But then again, we should have a safeguard... never know what those pesky users can do >.<.

#6 @rob1n
17 years ago

Also, changing milestone to 2.2 as this isn't a critical fix.

#7 @rob1n
17 years ago

See also #1956. Though I don't think we should transparently change the URL -- we should change the slug in the first place.

#8 @rob1n
17 years ago

  • Keywords dev-feedback 2nd-opinion added; categories removed

#9 @charleshooper
17 years ago

+1 on alerting the user. I feel that if a user tries to create a category with a specific slug the user should be alerted instead of us just silently changing the slug.

However it might also make sense to have WP change the slug on its own and then alert the user that such a change was made.

#10 @majelbstoat
17 years ago

The post slug is silently changed if that clashes, so this wouldn't be all that unexpected.

#11 @ryan
17 years ago

Category hierarchies need to be taken into account. Two categories named "Bar" are different if the y have different parents. /bar is not /foo/bar.

#12 @foolswisdom
17 years ago

  • Milestone changed from 2.2 to 2.3

#13 @jhodgdon
17 years ago

As of [5243], the behavior has been changed (I think it actually changed in [5148]).

Currently, what happens is that if you try to add a category with the same slug as an existing category, the code treats it as an update on the original category. However, on the screen it still says "added category abc", which is incorrect since all that happened was it updated existing category abc.

But anyway it is now impossible to add a category with the same slug as an existing category. Same name is still possible, but shouldn't cause any major difficulties (I tested this and didn't see any problems).

In my opinion, however, the existing behavior is undesirable.

#14 @rob1n
17 years ago

  • Status changed from assigned to new

#15 @rob1n
17 years ago

  • Priority changed from high to normal
  • Severity changed from major to normal

#16 @markjaquith
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed

It's now not possible to add a category with the same slug.

Note: See TracTickets for help on using tickets.