Make WordPress Core

Opened 7 months ago

Last modified 6 months ago

#61396 new defect (bug)

Duplicate terms with different cases with slug transliteration on the pre_insert_term hook — at Version 1

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

Change History (2)

#1 @oglekler
7 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;
			}
		}
	}
Note: See TracTickets for help on using tickets.