Make WordPress Core

Opened 15 years ago

Closed 13 years ago

Last modified 13 years ago

#18625 closed defect (bug) (invalid)

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

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

Description

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' )) 
		continue;
	else
		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
15 years ago

It depends on the MySQL collation you are using. WordPress uses by default utf8_general_ci. See http://dev.mysql.com/doc/refman/5.0/en/charset-collation-effect.html

#2 @xknown
15 years ago

Related to a collation issue #18210

#3 @abdessamad idrissi
15 years ago

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

#4 @SergeyBiryukov
15 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:

SET NAMES utf8;
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'), ('ṣḥḍ');

Now

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 $categories), your example works fine.

Last edited 15 years ago by SergeyBiryukov (previous) (diff)

#5 @ericmann
13 years ago

  • Resolutionworksforme
  • Status newclosed

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

#6 @dd32
13 years ago

  • Milestone Awaiting Review

#7 @SergeyBiryukov
13 years ago

  • Resolution worksformeinvalid
Note: See TracTickets for help on using tickets.