Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#18625 closed defect (bug) (invalid)

term_exists() doesn't make a difference between z and ẓ

Reported by: abdessamad-idrissi's profile abdessamad idrissi Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Taxonomy Keywords:
Focuses: Cc:


I spent hours before discouvering why wp_insert_term doesn't want to create some of my categories list;

$alphabet = array ( 
	array( 's', 'sth' ),
	array( 'ṣ', 'sth' ),
	array( 'h', 'sth' ),
	array( 'ḥ', 'sth' ),
	array( 'd', 'sth' ),
	array( 'ḍ', 'sth' )

foreach ($categories as $category ) 
	if( term_exists(  mb_strtolower($category[0]), 'category' )) 
		wp_insert_term( $category[0], 'category',  array( 'slug' => $category[0] ) );

term_exists() doesn't make a difference between "normal characters" and diacritic characters.

Change History (7)

#1 @xknown
12 years ago

It depends on the MySQL collation you are using. WordPress uses by default utf8_general_ci. See

#2 @xknown
12 years ago

Related to a collation issue #18210

#3 @abdessamad idrissi
12 years ago

I don't think it is related to MySQL collation because all my wp tables are utf8_general_ci

#4 @SergeyBiryukov
12 years ago

This depends on the MySQL collation indeed. I've modified the example from the link given by xknown above, to make it more clear.

To reproduce in MySQL:

CREATE TABLE utf8_general_test ( c CHAR(10) ) CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE TABLE utf8_bin_test (  c CHAR(10) ) CHARACTER SET utf8 COLLATE utf8_bin;

INSERT INTO utf8_general_test VALUES ('shd'), ('ṣḥḍ');
INSERT INTO utf8_bin_test VALUES ('shd'), ('ṣḥḍ');


SELECT * FROM utf8_general_test WHERE c = 'ṣḥḍ';

will return both values, whereas

SELECT * FROM utf8_bin_test WHERE c = 'ṣḥḍ';

will return only one.

I've tried to put

define('DB_COLLATE', 'utf8_bin');

to wp-config.php and reinstall WordPress (to create new tables in utf8_bin). After that (and changing $alphabet to $characters), your example works fine.

Version 1, edited 12 years ago by SergeyBiryukov (previous) (next) (diff)

#5 @ericmann
11 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

Based on the above comments, this appears to be a non-issue.

#6 @dd32
11 years ago

  • Milestone Awaiting Review deleted

#7 @SergeyBiryukov
11 years ago

  • Resolution changed from worksforme to invalid
Note: See TracTickets for help on using tickets.