Make WordPress Core

Opened 2 months ago

Last modified 8 weeks ago

#61396 new defect (bug)

Duplicate terms with names in non-ASCII characters in different cases

Reported by: oglekler's profile oglekler Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:

Description (last modified by oglekler)

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

Attachments (3)

2024-06-07_09-56-42.png (13.6 KB) - added by oglekler 2 months ago.
error_For_Ascii_duplicate.png (4.9 KB) - added by mai21 8 weeks ago.
Error with ASCII char
duplicated_nonAscii.png (28.7 KB) - added by mai21 8 weeks ago.
Duplicated non-ASCII char added to the table

Download all attachments as: .zip

Change History (8)

#1 @oglekler
2 months ago

  • Description modified (diff)

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;
			}
		}
	}

#2 @oglekler
2 months ago

  • Summary changed from Duplicate terms with different cases with slug transliteration on the pre_insert_term hook to Duplicate terms with names in non-ASCII characters in different cases

This ticket was mentioned in Slack in #core-test by mai21. View the logs.


8 weeks ago

#4 @mai21
8 weeks ago

@oglekler Thanks for reporting the issue.

Reproduction Report

Description

This report validates That the issue can be reproduced.

Environment

  • WordPress: 6.6-beta2-58396
  • PHP: 8.3.6
  • Server: nginx/1.24.0
  • Database: mysqli (Server: 10.6.16-MariaDB-0ubuntu0.22.04.1-log / Client: mysqlnd 8.3.6)
  • Browser: Chrome 125.0.0.0
  • OS: Linux
  • Theme: Twenty Eleven 4.6
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.1.0
    • WordPress Beta Tester 3.5.5

Steps

1- Open /domain/wp-admin/edit-tags.php
2- add 'test' as name
3- add 'Test' as name => error displayed 'A term with the name provided already exists in this taxonomy.' And slug is not added
4- add 'hа правописание' as name
5- add 'Hа правописание' as name => slug is added successfully and no error is displayed

Actual Results

🐞 How we deal with adding duplicate names isn't consistent while using /not using Non-ASCII char (reproduced).

Expected Results:

✅ Either an error is displayed with non-ASCII characters or no error is displayed for ASCII characters to be consistent

Last edited 8 weeks ago by mai21 (previous) (diff)

@mai21
8 weeks ago

Error with ASCII char

@mai21
8 weeks ago

Duplicated non-ASCII char added to the table

This ticket was mentioned in Slack in #core-test by mai21. View the logs.


8 weeks ago

Note: See TracTickets for help on using tickets.