diff --git a/src/mibew/install/dbperform.php b/src/mibew/install/dbperform.php index 6545614e..026ae192 100644 --- a/src/mibew/install/dbperform.php +++ b/src/mibew/install/dbperform.php @@ -63,9 +63,7 @@ if ($act == "silentcreateall") { mysql_query("CREATE DATABASE $mysqldb", $link) or show_install_err(' Query failed: ' . mysql_error($link)); } else { mysql_select_db($mysqldb, $link) or show_install_err('Could not select database'); - if ($force_charset_in_connection) { - mysql_query("SET character set utf8", $link); - } + mysql_query("SET character set utf8", $link); if ($act == "ct") { $curr_tables = get_tables($link); diff --git a/src/mibew/install/index.php b/src/mibew/install/index.php index 592adb99..db7d21f5 100644 --- a/src/mibew/install/index.php +++ b/src/mibew/install/index.php @@ -198,12 +198,11 @@ function check_connection() function check_database($link) { - global $mysqldb, $force_charset_in_connection, $page; + global $mysqldb, $page; if (mysql_select_db($mysqldb, $link)) { $page['done'][] = getlocal2("install.2.db_exists", array($mysqldb)); - if ($force_charset_in_connection) { - mysql_query("SET character set utf8", $link); - } + mysql_query("SET character set utf8", $link); + return true; } else { $page['nextstep'] = getlocal2("install.2.create", array($mysqldb)); diff --git a/src/mibew/libs/classes/Mibew/Database.php b/src/mibew/libs/classes/Mibew/Database.php index a50f6a06..84b4f6fd 100644 --- a/src/mibew/libs/classes/Mibew/Database.php +++ b/src/mibew/libs/classes/Mibew/Database.php @@ -71,24 +71,6 @@ class Database */ protected $tablesPrefix = ''; - /** - * Database connection encoding. Is used only if - * Database::$forceCharsetInConnection is set to true. - * @var string - * - * @see Database::$forceCharsetInConnection - */ - protected $dbEncoding = 'utf8'; - - /** - * Determine if connection must be forced to charset, specified in - * Database::$dbEncoding - * @var boolean - * - * @see Database::$dbEncoding - */ - protected $forceCharsetInConnection = true; - /** * Determine if connection to the database must be persistent * @var type @@ -156,20 +138,8 @@ class Database * database or not. * @param string $db Database name. * @param string $prefix Database tables prefix - * @param boolean $force_charset Control force charset in conection or not. - * @param string $encoding Contains connection encoding. Is used only if - * $force_charset is equals to TRUE. */ - public static function initialize( - $host, - $user, - $pass, - $use_pconn, - $db, - $prefix, - $force_charset = false, - $encoding = 'utf8' - ) { + public static function initialize($host, $user, $pass, $use_pconn, $db, $prefix) { // Check PDO if (!extension_loaded('PDO')) { throw new \Exception('PDO extension is not loaded'); @@ -192,9 +162,7 @@ class Database $instance->dbLogin = $user; $instance->dbPass = $pass; $instance->dbName = $db; - $instance->dbEncoding = $encoding; $instance->tablesPrefix = preg_replace('/[^A-Za-z0-9_$]/', '', $prefix); - $instance->forceCharsetInConnection = $force_charset; $instance->usePersistentConnection = $use_pconn; // Create PDO object @@ -205,9 +173,8 @@ class Database array(\PDO::ATTR_PERSISTENT => $instance->usePersistentConnection) ); - if ($instance->forceCharsetInConnection) { - $instance->dbh->exec("SET NAMES " . $instance->dbh->quote($instance->dbEncoding)); - } + // Force charset in all connections + $instance->dbh->exec("SET NAMES utf8"); // Store instance self::$instance = $instance; diff --git a/src/mibew/libs/default_config.php b/src/mibew/libs/default_config.php index 4d8f8275..c3c3227f 100644 --- a/src/mibew/libs/default_config.php +++ b/src/mibew/libs/default_config.php @@ -36,8 +36,6 @@ $mysqllogin = ""; $mysqlpass = ""; $mysqlprefix = ""; -$force_charset_in_connection = true; - $use_persistent_connection = false; /* diff --git a/src/mibew/libs/init.php b/src/mibew/libs/init.php index 5ab4022d..cb836ff1 100644 --- a/src/mibew/libs/init.php +++ b/src/mibew/libs/init.php @@ -80,9 +80,7 @@ session_start(); $mysqlpass, $use_persistent_connection, $mysqldb, - $mysqlprefix, - $force_charset_in_connection, - 'utf8' + $mysqlprefix ); if (function_exists("date_default_timezone_set")) {