diff options
author | Nils Wenninghoff <nils@ungemein.cool> | 2024-10-12 00:03:32 +0200 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2025-01-30 09:24:58 +0100 |
commit | cf5d55edb7501fcd8f28ec65986d0ee85c05d53a (patch) | |
tree | 31635fa5f64fb1fbc09520ce8faad7f973965e76 | |
parent | fce58d82fe13c507ecba2b1d447179a8b130a18a (diff) | |
download | nextcloud-server-cf5d55edb7501fcd8f28ec65986d0ee85c05d53a.tar.gz nextcloud-server-cf5d55edb7501fcd8f28ec65986d0ee85c05d53a.zip |
fix(ConvertType): Read dbtype in createConnectionParams and remove safeguard
Signed-off-by: Nils Wenninghoff <nils@ungemein.cool>
-rw-r--r-- | core/Command/Db/ConvertType.php | 9 | ||||
-rw-r--r-- | lib/private/DB/ConnectionFactory.php | 12 |
2 files changed, 6 insertions, 15 deletions
diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index b26494417ec..d7b0673e052 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -155,13 +155,6 @@ class ConvertType extends Command implements CompletionAwareInterface { } protected function execute(InputInterface $input, OutputInterface $output): int { - // WARNING: - // Leave in place until #45257 is addressed to prevent data loss (hopefully in time for the next maintenance release) - // - throw new \InvalidArgumentException( - 'This command is temporarily disabled (until the next maintenance release).' - ); - $this->validateInput($input, $output); $this->readPassword($input, $output); @@ -229,7 +222,7 @@ class ConvertType extends Command implements CompletionAwareInterface { protected function getToDBConnection(InputInterface $input, OutputInterface $output) { $type = $input->getArgument('type'); - $connectionParams = $this->connectionFactory->createConnectionParams(); + $connectionParams = $this->connectionFactory->createConnectionParams(type: $type); $connectionParams = array_merge($connectionParams, [ 'host' => $input->getArgument('hostname'), 'user' => $input->getArgument('username'), diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php index 8d662b0508c..4d286cb3068 100644 --- a/lib/private/DB/ConnectionFactory.php +++ b/lib/private/DB/ConnectionFactory.php @@ -108,7 +108,7 @@ class ConnectionFactory { $normalizedType = $this->normalizeType($type); $eventManager = new EventManager(); $eventManager->addEventSubscriber(new SetTransactionIsolationLevel()); - $connectionParams = $this->createConnectionParams('', $additionalConnectionParams); + $connectionParams = $this->createConnectionParams('', $additionalConnectionParams, $type); switch ($normalizedType) { case 'pgsql': // pg_connect used by Doctrine DBAL does not support URI notation (enclosed in brackets) @@ -175,12 +175,10 @@ class ConnectionFactory { /** * Create the connection parameters for the config - * - * @param string $configPrefix - * @return array */ - public function createConnectionParams(string $configPrefix = '', array $additionalConnectionParams = []) { - $type = $this->config->getValue('dbtype', 'sqlite'); + public function createConnectionParams(string $configPrefix = '', array $additionalConnectionParams = [], ?string $type = null) { + // use provided type or if null use type from config + $type = $type ?? $this->config->getValue('dbtype', 'sqlite'); $connectionParams = array_merge($this->getDefaultConnectionParams($type), [ 'user' => $this->config->getValue($configPrefix . 'dbuser', $this->config->getValue('dbuser', '')), @@ -212,7 +210,7 @@ class ConnectionFactory { 'tablePrefix' => $connectionParams['tablePrefix'] ]; - if ($this->config->getValue('mysql.utf8mb4', false)) { + if ($type === 'mysql' && $this->config->getValue('mysql.utf8mb4', false)) { $connectionParams['defaultTableOptions'] = [ 'collate' => 'utf8mb4_bin', 'charset' => 'utf8mb4', |