summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/database.mysql.inc12
-rw-r--r--includes/database.mysqli.inc8
-rw-r--r--includes/database.pgsql.inc10
-rw-r--r--includes/install.inc4
4 files changed, 31 insertions, 3 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;
}
diff --git a/includes/database.mysqli.inc b/includes/database.mysqli.inc
index 8645b7378..3fba6092f 100644
--- a/includes/database.mysqli.inc
+++ b/includes/database.mysqli.inc
@@ -71,6 +71,14 @@ function db_connect($url) {
exit;
}
+ /* Force UTF-8 */
+ mysqli_query($connection, 'SET NAMES "utf8"');
+ mysqli_query($connection, 'SET collation_connection="utf8_general_ci"');
+ mysqli_query($connection, 'SET collation_server="utf8_general_ci"');
+ mysqli_query($connection, 'SET character_set_client="utf8"');
+ mysqli_query($connection, 'SET character_set_connection="utf8"');
+ mysqli_query($connection, 'SET character_set_results="utf8"');
+ mysqli_query($connection, 'SET character_set_server="utf8"');
/**
* from: http://bugs.php.net/bug.php?id=33772
diff --git a/includes/database.pgsql.inc b/includes/database.pgsql.inc
index 89e6b9d7b..8375c6366 100644
--- a/includes/database.pgsql.inc
+++ b/includes/database.pgsql.inc
@@ -335,6 +335,16 @@ function db_unlock_tables() {
}
/**
+ * Verify if the database is set up correctly.
+ */
+function db_check_setup() {
+ $encoding = db_result(db_query('SHOW server_encoding'));
+ if (!in_array(strtolower($encoding), array('unicode', 'utf8'))) {
+ drupal_set_message(t('Your PostgreSQL database is set up with the wrong character encoding (%encoding). It is possibile it will not work as expected. It is advised to recreate it with UTF-8/Unicode encoding. More information can be found in the <a href="%url">PostgreSQL documentation</a>.', array('%encoding' => $encoding, '%url' => 'http://www.postgresql.org/docs/7.4/interactive/multibyte.html')), 'status');
+ }
+}
+
+/**
* @} End of "ingroup database".
*/
diff --git a/includes/install.inc b/includes/install.inc
index c62039091..b9db13c97 100644
--- a/includes/install.inc
+++ b/includes/install.inc
@@ -1,8 +1,8 @@
<?php
// $Id$
-define('SCHEMA', 0);
-define('SCHEMA_MIN', 1);
+define('SCHEMA_UNINSTALLED', -1);
+define('SCHEMA_INSTALLED', 0);
// The system module (Drupal core) is currently a special case