[wp-trac] [WordPress Trac] #61396: Duplicate terms with different cases with slug transliteration on the pre_insert_term hook

WordPress Trac noreply at wordpress.org
Fri Jun 7 07:33:00 UTC 2024


#61396: Duplicate terms with different cases with slug transliteration on the
pre_insert_term hook
--------------------------+------------------------------
 Reporter:  oglekler      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Old description:

> On the /wp-admin/edit-tags.php page, an attempt to add terms `Test` and
> `test` is leading to an error "A term with the name provided already
> exists in this taxonomy." and the term is not added, but if I am doing
> the same thing in Russian language with the usage of a plugin (CyrToLat
> in this case) that is making slug transliteration via the
> `pre_insert_term` filter, I am getting duplicate terms. I am not sure
> that this issue should be addressed to the plugin developer, because it
> looks like after filtering the term, we still need to ensure that this
> term is valid and comply with existing rules.
>
> @mihdan FYI

New description:

 On the /wp-admin/edit-tags.php page, an attempt to add terms `Test` and
 `test` is leading to an error "A term with the name provided already
 exists in this taxonomy." and the term is not added, but if I am doing the
 same thing in Russian language with the usage of a plugin (CyrToLat in
 this case) that is making slug transliteration via the `pre_insert_term`
 filter, I am getting duplicate terms. I am not sure that this issue should
 be addressed to the plugin developer, because it looks like after
 filtering the term, we still need to ensure that this term is valid and
 comply with existing rules.





 @mihdan FYI

--

Comment (by oglekler):

 `pre_insert_term` filter is only for the term itself and not filtering all
 $args and the plugin in question had only one opportunity to transliterate
 slug hooking sanitize_title(), which looks like a last resort instead of
 expected behavior, but this is not the source of the issue.

 The source of trouble is strtolower(), which is only converting ASCII
 characters 🤦


 {{{
         $name_match = null;
         if ( $name_matches ) {
                 foreach ( $name_matches as $_match ) {
                         if ( strtolower( $name ) === strtolower(
 $_match->name ) ) {
                                 $name_match = $_match;
                                 break;
                         }
                 }
         }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61396#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list