[DATABASE] Make sure the session always uses UTF-8 and UTC
This commit is contained in:
parent
4e02cb437a
commit
7e1091eb8c
@ -894,11 +894,14 @@ class Memcached_DataObject extends Safe_DataObject
|
|||||||
$result = parent::_connect();
|
$result = parent::_connect();
|
||||||
|
|
||||||
if ($result && !$exists) {
|
if ($result && !$exists) {
|
||||||
// Needed to make timestamp values usefully comparable.
|
// Required to make timestamp values usefully comparable.
|
||||||
|
// And set the character set to UTF-8.
|
||||||
if (common_config('db', 'type') !== 'mysql') {
|
if (common_config('db', 'type') !== 'mysql') {
|
||||||
parent::_query("SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE");
|
parent::_query("SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE");
|
||||||
|
parent::_query("SET NAMES 'UTF8'");
|
||||||
} else {
|
} else {
|
||||||
parent::_query("SET time_zone = '+0:00'");
|
parent::_query("SET time_zone = '+0:00'");
|
||||||
|
parent::_query("SET NAMES 'utf8mb4'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,6 +306,8 @@ abstract class Installer
|
|||||||
|
|
||||||
switch ($this->dbtype) {
|
switch ($this->dbtype) {
|
||||||
case 'pgsql':
|
case 'pgsql':
|
||||||
|
// ensure the timezone is UTC
|
||||||
|
$conn->query("SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE");
|
||||||
// ensure the database encoding is UTF8
|
// ensure the database encoding is UTF8
|
||||||
$conn->query("SET NAMES 'UTF8'");
|
$conn->query("SET NAMES 'UTF8'");
|
||||||
$server_encoding = $conn->getRow('SHOW server_encoding')[0];
|
$server_encoding = $conn->getRow('SHOW server_encoding')[0];
|
||||||
@ -313,11 +315,13 @@ abstract class Installer
|
|||||||
$this->updateStatus(
|
$this->updateStatus(
|
||||||
'GNU social requires the UTF8 character encoding. Yours is ' .
|
'GNU social requires the UTF8 character encoding. Yours is ' .
|
||||||
htmlentities($server_encoding)
|
htmlentities($server_encoding)
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
|
// ensure the timezone is UTC
|
||||||
|
$conn->query("SET time_zone = '+0:00'");
|
||||||
// ensure the database encoding is utf8mb4
|
// ensure the database encoding is utf8mb4
|
||||||
$conn->query("SET NAMES 'utf8mb4'");
|
$conn->query("SET NAMES 'utf8mb4'");
|
||||||
$server_encoding = $conn->getRow("SHOW VARIABLES LIKE 'character_set_server'")[1];
|
$server_encoding = $conn->getRow("SHOW VARIABLES LIKE 'character_set_server'")[1];
|
||||||
@ -340,10 +344,11 @@ abstract class Installer
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (['sms_carrier' => 'SMS carrier',
|
foreach ([
|
||||||
'notice_source' => 'notice source',
|
'sms_carrier' => 'SMS carrier',
|
||||||
'foreign_services' => 'foreign service']
|
'notice_source' => 'notice source',
|
||||||
as $scr => $name) {
|
'foreign_services' => 'foreign service',
|
||||||
|
] as $scr => $name) {
|
||||||
$this->updateStatus(sprintf("Adding %s data to database...", $name));
|
$this->updateStatus(sprintf("Adding %s data to database...", $name));
|
||||||
$res = $this->runDbScript($scr . '.sql', $conn);
|
$res = $this->runDbScript($scr . '.sql', $conn);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
|
Loading…
Reference in New Issue
Block a user