[DATABASE] Make sure the session always uses UTF-8 and UTC

This commit is contained in:
Alexei Sorokin
2020-09-12 15:40:39 +03:00
committed by Diogo Peralta Cordeiro
parent 4e02cb437a
commit 7e1091eb8c
2 changed files with 14 additions and 6 deletions

View File

@@ -894,11 +894,14 @@ class Memcached_DataObject extends Safe_DataObject
$result = parent::_connect();
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') {
parent::_query("SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE");
parent::_query("SET NAMES 'UTF8'");
} else {
parent::_query("SET time_zone = '+0:00'");
parent::_query("SET NAMES 'utf8mb4'");
}
}