From af92e6f7eb3bf617c802b0b6328f8878d8b12f4f Mon Sep 17 00:00:00 2001 From: Yip Rui Fung Date: Thu, 4 Feb 2021 13:52:17 +0800 Subject: [PATCH] Allow defaultTableOptions to be overridden from configuration. Signed-off-by: Yip Rui Fung --- config/config.sample.php | 15 +++++++++++++++ lib/private/DB/ConnectionFactory.php | 14 +++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/config/config.sample.php b/config/config.sample.php index 9824749a25..7aaa98f831 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -1512,6 +1512,21 @@ $CONFIG = [ */ 'mysql.utf8mb4' => false, +/** + * This configuration parameter can be used to override the default options used for table creation. + * This parameter will take precedence over mysql.utf8mb4 if that is set to true. + * + * 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/remove the row_format option. + * + */ +'dbdefaulttableoptions' => [ + 'collate' => 'utf8mb4_bin', + 'charset' => 'utf8mb4', + 'row_format' => 'compressed' +], + /** * Database types that are supported for installation. * diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php index 441e4567db..4ba606f5dd 100644 --- a/lib/private/DB/ConnectionFactory.php +++ b/lib/private/DB/ConnectionFactory.php @@ -216,20 +216,20 @@ class ConnectionFactory { } // set default table creation options - $connectionParams['defaultTableOptions'] = [ - 'collate' => 'utf8_bin', - 'tablePrefix' => $connectionParams['tablePrefix'] - ]; + $connectionParams['defaultTableOptions'] = $this->config->getValue('dbdefaulttableoptions', [ + 'collate' => 'utf8_bin' + ]); - if ($this->config->getValue('mysql.utf8mb4', false)) { + if ($this->config->getValue('mysql.utf8mb4', false) && is_null($this->config->getValue('dbdefaulttableoptions'))) { $connectionParams['defaultTableOptions'] = [ 'collate' => 'utf8mb4_bin', 'charset' => 'utf8mb4', - 'row_format' => 'compressed', - 'tablePrefix' => $connectionParams['tablePrefix'] + 'row_format' => 'compressed' ]; } + $connectionParams['defaultTableOptions']['tablePrefix'] = $connectionParams['tablePrefix']; + return $connectionParams; }