This commit is contained in:
Yip Rui Fung 2021-06-03 22:29:52 +02:00 committed by GitHub
commit 6e704f6496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View File

@ -1524,6 +1524,20 @@ $CONFIG = [
*/
'mysql.utf8mb4' => false,
/**
* This configuration parameter can be used to add or change the default options used for table creation.
* For changing charset / collation see mysql.utf8mb4
*
* An example use for this parameter is where MariaDB page compression is enabled by default as the
* COMPRESSED row format is not allowed there, and thus table creation will fail.
* This option can then be used to override this and change the row_format option.
*
*/
'dbdefaulttableoptions' => [
'row_format' => 'dynamic',
'page_compressed' => '1'
],
/**
* Database types that are supported for installation.
*

View File

@ -216,13 +216,13 @@ class ConnectionFactory {
}
// set default table creation options
$connectionParams['defaultTableOptions'] = [
$defaultTableOptions = [
'collate' => 'utf8_bin',
'tablePrefix' => $connectionParams['tablePrefix']
];
if ($this->config->getValue('mysql.utf8mb4', false)) {
$connectionParams['defaultTableOptions'] = [
$defaultTableOptions = [
'collate' => 'utf8mb4_bin',
'charset' => 'utf8mb4',
'row_format' => 'compressed',
@ -230,6 +230,21 @@ class ConnectionFactory {
];
}
$configTableOptions = $this->config->getValue('dbdefaulttableoptions', []);
// prevent user from overriding collation / charset and tablePrefix here (previous behavior.)
if (array_key_exists('collate', $configTableOptions)) {
unset($configTableOptions['collate']);
}
if (array_key_exists('charset', $configTableOptions)) {
unset($configTableOptions['charset']);
}
if (array_key_exists('tablePrefix', $configTableOptions)) {
unset($configTableOptions['tablePrefix']);
}
$connectionParams['defaultTableOptions'] = array_merge($defaultTableOptions, $configTableOptions);
return $connectionParams;
}