Opened 12 years ago
Closed 11 years ago
#24216 closed defect (bug) (duplicate)
wp_unique_term_slug uses variable that doesn't exist
Reported by: | lonnylot | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.5 |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description (last modified by )
http://core.trac.wordpress.org/browser/trunk/wp-includes/taxonomy.php#L2380
$args['term_id']
doesn't exist. It should be $term->term_id
.
This means that even though the DB schema allows for different taxonomies to have the same slug the code will never allow it.
Attachments (1)
Change History (7)
#3
@
12 years ago
On further inspection the whole 'unique slug' system is a little faulty. I'm not sure if this warrents a new ticket or if the scope of this ticket should be broadened, but I wanted to make a note of it.
If you create a category w/ the name of 'Foo' and the slug 'foo' automatically gets created. Create a new category with the name of 'foo' and the slug 'foo-2' gets created. This works properly, but here is the problem:
If you create a new category w/ the name of 'Foo' you get 'A term with the name provided already exists with this parent.', but if you create a new category w/ the name of 'foo' you get a new category w/ a slug of 'foo-3'.
#5
@
11 years ago
I had a look at this today and I believe the part referenced in the ticket can simply be removed. Using
$term->term_id
does not work, as $term was originally cast to stdClass from $args and does not have this property. You could look up the ID again, or make more changes so we can pass the ID, but I'm not sure that is necessary as the method to get the numbered slug has worked like that for years now?
As mentioned in the comment above, there are many more things going wrong here, and I'm not sure what the intended behaviour is, else I would look into it further. According to the codex, there should never be duplicate names, not even for terms with different parents. However currently it seems only the first returned name is checked against, and lower/upper case is not taken into account. Duplicate names within other parents seem also possible.
Introduced in [6326].