WordPress.org

Make WordPress Core

Opened 17 months ago

#50229 new defect (bug)

slugs aren't allowed as long as they're in different taxonomies.

Reported by: trasweb Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4.1
Component: Taxonomy Keywords:
Focuses: Cc:

Description

Hello,

I write relative to a bug in taxonomies. From [WP 4.1, duplicate slugs are allowed as long as they're in different taxonomies](https://core.trac.wordpress.org/browser/tags/5.4/src/wp-includes/taxonomy.php#L2710). However, this isn't currently so.

Example:

Taxonomy one with two terms: "one1", "one1-2". Both are slug.
Taxonomy two with a term: "one1"( slug )

  1. I create term with slug 'one1'.
  2. Checking of duplicated slug is in [wp_unique_term_slug]( https://core.trac.wordpress.org/browser/tags/5.4/src/wp-includes/taxonomy.php#L2710 )
  3. [if is true](https://core.trac.wordpress.org/browser/tags/5.4/src/wp-includes/taxonomy.php#L2711), so that needs_suffix is true.
  4. Query result of [line 2758](https://core.trac.wordpress.org/browser/tags/5.4/src/wp-includes/taxonomy.php#L2758) is a row( 'one1' of Taxonomy two )
  5. one1-2 is $alt-slug in [L2764](https://core.trac.wordpress.org/browser/tags/5.4/src/wp-includes/taxonomy.php#L2764)
  6. Finally, query in [L2766](https://core.trac.wordpress.org/browser/tags/5.4/src/wp-includes/taxonomy.php#L2766) returns a row( "one1-2" of Taxonomy 1 ).

Conclusion: same slug with two different taxonomies aren't allowed.

Maybe, queries in this method, should be replaced with get_term_by in order to check also taxonomy.

Regards
Manuel Canga

Change History (0)

Note: See TracTickets for help on using tickets.