diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-09-04 09:32:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-04 09:32:21 +0200 |
commit | c28340dd5b8adc5f686e3c42706a5214ea0035ea (patch) | |
tree | 467f0d4335f763c36926ee51d71ee3f7bd12eda8 /core/Command | |
parent | e11a8f0bc5aab3b6119c7adb36c2272868ecc565 (diff) | |
parent | 71fff03e9bc9e1b1074a6a993d43f041e95c782b (diff) | |
download | nextcloud-server-c28340dd5b8adc5f686e3c42706a5214ea0035ea.tar.gz nextcloud-server-c28340dd5b8adc5f686e3c42706a5214ea0035ea.zip |
Merge pull request #39242 from joshtrichards/db-convert-type-mysql-socket-no-pw
Diffstat (limited to 'core/Command')
-rw-r--r-- | core/Command/Db/ConvertType.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index 592285a8309..031d5a83d12 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -142,10 +142,13 @@ class ConvertType extends Command implements CompletionAwareInterface { if ($input->isInteractive()) { /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); - $question = new Question('What is the database password?'); + $question = new Question('What is the database password (press <enter> for none)? '); $question->setHidden(true); $question->setHiddenFallback(false); $password = $helper->ask($input, $output, $question); + if ($password === null) { + $password = ''; // possibly unnecessary + } $input->setOption('password', $password); return; } @@ -233,9 +236,24 @@ class ConvertType extends Command implements CompletionAwareInterface { 'password' => $input->getOption('password'), 'dbname' => $input->getArgument('database'), ]); + + // parse port if ($input->getOption('port')) { $connectionParams['port'] = $input->getOption('port'); } + + // parse hostname for unix socket + if (preg_match('/^(.+)(:(\d+|[^:]+))?$/', $input->getOption('hostname'), $matches)) { + $connectionParams['host'] = $matches[1]; + if (isset($matches[3])) { + if (is_numeric($matches[3])) { + $connectionParams['port'] = $matches[3]; + } else { + $connectionParams['unix_socket'] = $matches[3]; + } + } + } + return $this->connectionFactory->getConnection($type, $connectionParams); } |