diff --git a/config/config.sample.php b/config/config.sample.php index 4895b6a7c8..5343bb8b02 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -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. * diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php index 441e4567db..9ed8b87747 100644 --- a/lib/private/DB/ConnectionFactory.php +++ b/lib/private/DB/ConnectionFactory.php @@ -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; }