[wp-trac] [WordPress Trac] #50229: slugs aren't allowed as long as they're in different taxonomies.
WordPress Trac
noreply at wordpress.org
Fri May 22 22:31:36 UTC 2020
#50229: slugs aren't allowed as long as they're in different taxonomies.
--------------------------+-----------------------------
Reporter: trasweb | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 5.4.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
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
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50229>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list