mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-21 14:22:23 +08:00
MySQL use utf8mb4 instead of the old utf8
This commit is contained in:
parent
89cbcf6f63
commit
c67d77bd57
3 changed files with 33 additions and 30 deletions
|
@ -804,13 +804,10 @@ class Actions
|
|||
(\MailSo\Base\Utils::FunctionExistsAndEnabled('php_sapi_name') ? \php_sapi_name() : '~') . ']'
|
||||
);
|
||||
|
||||
$sPdo = (\class_exists('PDO') ? \implode(',', \PDO::getAvailableDrivers()) : 'off');
|
||||
$sPdo = empty($sPdo) ? '~' : $sPdo;
|
||||
|
||||
$this->oLogger->Write(
|
||||
'[APC:' . (\MailSo\Base\Utils::FunctionExistsAndEnabled('apc_fetch') ? 'on' : 'off') .
|
||||
'][MB:' . (\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_convert_encoding') ? 'on' : 'off') .
|
||||
'][PDO:' . $sPdo .
|
||||
'][PDO:' . (\class_exists('PDO') ? (\implode(',', \Pdo::getAvailableDrivers()) ?: '~') : 'off') .
|
||||
'][Streams:' . \implode(',', \stream_get_transports()) .
|
||||
']');
|
||||
|
||||
|
@ -1187,7 +1184,7 @@ class Actions
|
|||
$aResult['VerifySslCertificate'] = (bool)$oConfig->Get('ssl', 'verify_certificate', false);
|
||||
$aResult['AllowSelfSigned'] = (bool)$oConfig->Get('ssl', 'allow_self_signed', true);
|
||||
|
||||
$aResult['supportedPdoDrivers'] = \class_exists('PDO') ? \PDO::getAvailableDrivers() : [];
|
||||
$aResult['supportedPdoDrivers'] = \class_exists('PDO') ? \RainLoop\Common\PdoAbstract::getAvailableDrivers() : [];
|
||||
|
||||
$aResult['ContactsEnable'] = (bool)$oConfig->Get('contacts', 'enable', false);
|
||||
$aResult['ContactsSync'] = (bool)$oConfig->Get('contacts', 'allow_sync', false);
|
||||
|
@ -2262,7 +2259,7 @@ class Actions
|
|||
|
||||
public function ValidateContactPdoType(string $sType): string
|
||||
{
|
||||
return \in_array($sType, array('mysql', 'pgsql', 'sqlite')) ? $sType : 'sqlite';
|
||||
return \in_array($sType, \RainLoop\Common\PdoAbstract::getAvailableDrivers()) ? $sType : 'sqlite';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,6 +50,13 @@ abstract class PdoAbstract
|
|||
return \strcmp(\mb_strtoupper($sStr1, 'UTF-8'), \mb_strtoupper($sStr2, 'UTF-8'));
|
||||
}
|
||||
|
||||
public static function getAvailableDrivers() : array
|
||||
{
|
||||
return \class_exists('PDO')
|
||||
? array_intersect(['mysql', 'sqlite', 'pgsql'], \PDO::getAvailableDrivers())
|
||||
: [];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws \Exception
|
||||
|
@ -69,7 +76,7 @@ abstract class PdoAbstract
|
|||
$sType = $sDsn = $sDbLogin = $sDbPassword = '';
|
||||
list($sType, $sDsn, $sDbLogin, $sDbPassword) = $this->getPdoAccessData();
|
||||
|
||||
if (!\in_array($sType, array('mysql', 'sqlite', 'pgsql')))
|
||||
if (!\in_array($sType, static::getAvailableDrivers()))
|
||||
{
|
||||
throw new \Exception('Unknown PDO SQL connection type');
|
||||
}
|
||||
|
@ -85,7 +92,7 @@ abstract class PdoAbstract
|
|||
try
|
||||
{
|
||||
// $bCaseFunc = false;
|
||||
$oPdo = @new \PDO($sDsn, $sDbLogin, $sDbPassword);
|
||||
$oPdo = new \PDO($sDsn, $sDbLogin, $sDbPassword);
|
||||
if ($oPdo)
|
||||
{
|
||||
$sPdoType = $oPdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
|
||||
|
@ -93,8 +100,7 @@ abstract class PdoAbstract
|
|||
|
||||
if ('mysql' === $sType && 'mysql' === $sPdoType)
|
||||
{
|
||||
$oPdo->exec('SET NAMES utf8 COLLATE utf8_general_ci');
|
||||
// $oPdo->exec('SET NAMES utf8');
|
||||
$oPdo->exec('SET NAMES utf8mb4 COLLATE utf8mb4_general_ci');
|
||||
}
|
||||
// else if ('sqlite' === $sType && 'sqlite' === $sPdoType && $this->bSqliteCollate)
|
||||
// {
|
||||
|
@ -374,13 +380,13 @@ value_int int UNSIGNED NOT NULL DEFAULT 0,
|
|||
value_str varchar(128) NOT NULL DEFAULT \'\',
|
||||
PRIMARY KEY(id),
|
||||
INDEX sys_name_rainloop_system_index (sys_name)
|
||||
) /*!40000 ENGINE=INNODB *//*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;';
|
||||
) ENGINE=INNODB CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;';
|
||||
$aQ[] = 'CREATE TABLE IF NOT EXISTS rainloop_users (
|
||||
id_user int UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
rl_email varchar(128) NOT NULL DEFAULT \'\',
|
||||
PRIMARY KEY(id_user),
|
||||
INDEX rl_email_rainloop_users_index (rl_email)
|
||||
) /*!40000 ENGINE=INNODB */;';
|
||||
) ENGINE=INNODB;';
|
||||
break;
|
||||
|
||||
case 'pgsql':
|
||||
|
|
|
@ -41,7 +41,7 @@ class PdoAddressBook
|
|||
|
||||
public function IsSupported() : bool
|
||||
{
|
||||
$aDrivers = \class_exists('PDO') ? \PDO::getAvailableDrivers() : array();
|
||||
$aDrivers = static::getAvailableDrivers();
|
||||
return \is_array($aDrivers) && \in_array($this->sDsnType, $aDrivers);
|
||||
}
|
||||
|
||||
|
@ -1628,36 +1628,36 @@ class PdoAddressBook
|
|||
|
||||
CREATE TABLE IF NOT EXISTS rainloop_ab_contacts (
|
||||
|
||||
id_contact bigint UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
id_contact_str varchar(128) NOT NULL DEFAULT '',
|
||||
id_user int UNSIGNED NOT NULL,
|
||||
display varchar(255) NOT NULL DEFAULT '',
|
||||
changed int UNSIGNED NOT NULL DEFAULT 0,
|
||||
deleted tinyint UNSIGNED NOT NULL DEFAULT 0,
|
||||
etag varchar(128) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL DEFAULT '',
|
||||
id_contact bigint UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
id_contact_str varchar(128) NOT NULL DEFAULT '',
|
||||
id_user int UNSIGNED NOT NULL,
|
||||
display varchar(255) NOT NULL DEFAULT '',
|
||||
changed int UNSIGNED NOT NULL DEFAULT 0,
|
||||
deleted tinyint UNSIGNED NOT NULL DEFAULT 0,
|
||||
etag varchar(128) NOT NULL DEFAULT '' CHARACTER SET ascii COLLATE ascii_general_ci,
|
||||
|
||||
PRIMARY KEY(id_contact),
|
||||
INDEX id_user_rainloop_ab_contacts_index (id_user)
|
||||
|
||||
)/*!40000 ENGINE=INNODB *//*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||
) ENGINE=INNODB CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS rainloop_ab_properties (
|
||||
|
||||
id_prop bigint UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
id_contact bigint UNSIGNED NOT NULL,
|
||||
id_user int UNSIGNED NOT NULL,
|
||||
prop_type tinyint UNSIGNED NOT NULL,
|
||||
prop_type_str varchar(255) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL DEFAULT '',
|
||||
prop_value varchar(255) NOT NULL DEFAULT '',
|
||||
prop_value_custom varchar(255) NOT NULL DEFAULT '',
|
||||
prop_frec int UNSIGNED NOT NULL DEFAULT 0,
|
||||
id_prop bigint UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
id_contact bigint UNSIGNED NOT NULL,
|
||||
id_user int UNSIGNED NOT NULL,
|
||||
prop_type tinyint UNSIGNED NOT NULL,
|
||||
prop_type_str varchar(255) NOT NULL DEFAULT '' CHARACTER SET ascii COLLATE ascii_general_ci,
|
||||
prop_value varchar(255) NOT NULL DEFAULT '',
|
||||
prop_value_custom varchar(255) NOT NULL DEFAULT '',
|
||||
prop_frec int UNSIGNED NOT NULL DEFAULT 0,
|
||||
|
||||
PRIMARY KEY(id_prop),
|
||||
INDEX id_user_rainloop_ab_properties_index (id_user),
|
||||
INDEX id_user_id_contact_rainloop_ab_properties_index (id_user, id_contact),
|
||||
INDEX id_contact_prop_type_rainloop_ab_properties_index (id_contact, prop_type)
|
||||
|
||||
)/*!40000 ENGINE=INNODB *//*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||
) ENGINE=INNODB CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
|
||||
MYSQLINITIAL;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue