Set the character set before making a connection
Ideally the character set should be set with the connection, and so this is exactly what's being done now. And now the character set code is attempted to be generalised.
This commit is contained in:
@@ -49,6 +49,11 @@ class SQLStore_DB_Connection extends Auth_OpenID_DatabaseConnection
|
||||
}
|
||||
$dsn['new_link'] = true;
|
||||
|
||||
if (array_key_exists('charset', $options)) {
|
||||
$dsn['charset'] = $options['charset'];
|
||||
unset($options['charset']);
|
||||
}
|
||||
|
||||
// To create a new Database connection is an absolute must, because
|
||||
// php-openid code delays its transactions commitment.
|
||||
// Is a must because our Internal Session Handler uses the database
|
||||
|
@@ -45,6 +45,9 @@ function oid_store()
|
||||
if (!is_array($options)) {
|
||||
$options = [];
|
||||
}
|
||||
// A special case, carry the charset.
|
||||
$options['charset'] = common_database_charset();
|
||||
|
||||
$dbconn = new SQLStore_DB_Connection($dsn, $options);
|
||||
|
||||
switch (common_config('db', 'type')) {
|
||||
|
@@ -39,11 +39,11 @@ END_OF_TRIM_HELP;
|
||||
require_once INSTALLDIR . '/scripts/commandline.inc';
|
||||
require dirname(__FILE__) . '/sphinx-utils.php';
|
||||
|
||||
|
||||
$base = $base ?? '/usr/local';
|
||||
$timestamp = date('r');
|
||||
print <<<END
|
||||
echo <<<END
|
||||
#
|
||||
# Sphinx configuration for StatusNet
|
||||
# Sphinx configuration for GNU social
|
||||
# Generated {$timestamp}
|
||||
#
|
||||
|
||||
@@ -109,8 +109,9 @@ function sphinx_template($sn, $table, $query, $query_info)
|
||||
{
|
||||
$base = sphinx_base();
|
||||
$dbtype = common_config('db', 'type');
|
||||
$charset = common_database_charset();
|
||||
|
||||
print <<<END
|
||||
echo <<<END
|
||||
|
||||
#
|
||||
# {$sn->sitename}
|
||||
@@ -122,7 +123,7 @@ source {$sn->dbname}_src_{$table}
|
||||
sql_user = {$sn->dbuser}
|
||||
sql_pass = {$sn->dbpass}
|
||||
sql_db = {$sn->dbname}
|
||||
sql_query_pre = SET NAMES utf8;
|
||||
sql_query_pre = SET NAMES '{$charset}';
|
||||
sql_query = {$query}
|
||||
sql_query_info = {$query_info}
|
||||
sql_attr_timestamp = created_ts
|
||||
|
Reference in New Issue
Block a user