Skip to content

Commit 16921d7

Browse files
Merge pull request #50530 from nextcloud/fix/convert-type
2 parents 8604389 + d8cc8aa commit 16921d7

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

core/Command/Db/ConvertType.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,6 @@ protected function readPassword(InputInterface $input, OutputInterface $output)
155155
}
156156

157157
protected function execute(InputInterface $input, OutputInterface $output): int {
158-
// WARNING:
159-
// Leave in place until #45257 is addressed to prevent data loss (hopefully in time for the next maintenance release)
160-
//
161-
throw new \InvalidArgumentException(
162-
'This command is temporarily disabled (until the next maintenance release).'
163-
);
164-
165158
$this->validateInput($input, $output);
166159
$this->readPassword($input, $output);
167160

@@ -229,7 +222,7 @@ protected function createSchema(Connection $fromDB, Connection $toDB, InputInter
229222

230223
protected function getToDBConnection(InputInterface $input, OutputInterface $output) {
231224
$type = $input->getArgument('type');
232-
$connectionParams = $this->connectionFactory->createConnectionParams();
225+
$connectionParams = $this->connectionFactory->createConnectionParams(type: $type);
233226
$connectionParams = array_merge($connectionParams, [
234227
'host' => $input->getArgument('hostname'),
235228
'user' => $input->getArgument('username'),
@@ -243,7 +236,7 @@ protected function getToDBConnection(InputInterface $input, OutputInterface $out
243236
}
244237

245238
// parse hostname for unix socket
246-
if (preg_match('/^(.+)(:(\d+|[^:]+))?$/', $input->getOption('hostname'), $matches)) {
239+
if (preg_match('/^(.+)(:(\d+|[^:]+))?$/', $input->getArgument('hostname'), $matches)) {
247240
$connectionParams['host'] = $matches[1];
248241
if (isset($matches[3])) {
249242
if (is_numeric($matches[3])) {

lib/private/DB/ConnectionFactory.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getConnection(string $type, array $additionalConnectionParams):
108108
$normalizedType = $this->normalizeType($type);
109109
$eventManager = new EventManager();
110110
$eventManager->addEventSubscriber(new SetTransactionIsolationLevel());
111-
$connectionParams = $this->createConnectionParams('', $additionalConnectionParams);
111+
$connectionParams = $this->createConnectionParams('', $additionalConnectionParams, $type);
112112
switch ($normalizedType) {
113113
case 'pgsql':
114114
// pg_connect used by Doctrine DBAL does not support URI notation (enclosed in brackets)
@@ -175,12 +175,10 @@ public function isValidType($type) {
175175

176176
/**
177177
* Create the connection parameters for the config
178-
*
179-
* @param string $configPrefix
180-
* @return array
181178
*/
182-
public function createConnectionParams(string $configPrefix = '', array $additionalConnectionParams = []) {
183-
$type = $this->config->getValue('dbtype', 'sqlite');
179+
public function createConnectionParams(string $configPrefix = '', array $additionalConnectionParams = [], ?string $type = null) {
180+
// use provided type or if null use type from config
181+
$type = $type ?? $this->config->getValue('dbtype', 'sqlite');
184182

185183
$connectionParams = array_merge($this->getDefaultConnectionParams($type), [
186184
'user' => $this->config->getValue($configPrefix . 'dbuser', $this->config->getValue('dbuser', '')),
@@ -212,7 +210,7 @@ public function createConnectionParams(string $configPrefix = '', array $additio
212210
'tablePrefix' => $connectionParams['tablePrefix']
213211
];
214212

215-
if ($this->config->getValue('mysql.utf8mb4', false)) {
213+
if ($type === 'mysql' && $this->config->getValue('mysql.utf8mb4', false)) {
216214
$connectionParams['defaultTableOptions'] = [
217215
'collate' => 'utf8mb4_bin',
218216
'charset' => 'utf8mb4',

0 commit comments

Comments
 (0)