diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-01-21 01:42:52 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-01-21 01:42:52 +0000 |
commit | 7914ad0f3f9b29d78e7321ad9addbff99de48a4f (patch) | |
tree | bb97f37f191c966993a9607daa9f4168591dd68c /includes/database.mysql.inc | |
parent | 0ff0c4beaaf0ae49e8b9b7afeda83a26d8d59666 (diff) | |
download | brdo-7914ad0f3f9b29d78e7321ad9addbff99de48a4f.tar.gz brdo-7914ad0f3f9b29d78e7321ad9addbff99de48a4f.tar.bz2 |
- #40515: Ensure UTF-8 character set on the database side (and include upgrade path for incorrectly set up databases)
Diffstat (limited to 'includes/database.mysql.inc')
-rw-r--r-- | includes/database.mysql.inc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/includes/database.mysql.inc b/includes/database.mysql.inc index c41e00494..445a79816 100644 --- a/includes/database.mysql.inc +++ b/includes/database.mysql.inc @@ -62,7 +62,7 @@ function db_connect($url) { if (!mysql_select_db(substr($url['path'], 1))) { drupal_maintenance_theme(); drupal_set_title('Unable to select database'); - print theme('maintenance_page', '<p>We were able to connect to the MySQL database server (which means your username and password is okay) but not able to select the database.</p> + print theme('maintenance_page', '<p>We were able to connect to the MySQL database server (which means your username and password are okay) but not able to select the database.</p> <p>The MySQL error was: '. theme('placeholder', mysql_error($connection)) .'.</p> <p>Currently, the database is '. theme('placeholder', substr($url['path'], 1)) .'. The username is '. theme('placeholder', $url['user']) .' and the database server is '. theme('placeholder', $url['host']) .'.</p> <ul> @@ -74,6 +74,16 @@ function db_connect($url) { exit; } + /* On MySQL 4.1 and later, force UTF-8 */ + if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) { + mysql_query('SET NAMES "utf8"', $connection); + mysql_query('SET collation_connection="utf8_general_ci"', $connection); + mysql_query('SET collation_server="utf8_general_ci"', $connection); + mysql_query('SET character_set_client="utf8"', $connection); + mysql_query('SET character_set_connection="utf8"', $connection); + mysql_query('SET character_set_results="utf8"', $connection); + mysql_query('SET character_set_server="utf8"', $connection); + } return $connection; } |