Skip to content

Commit

Permalink
fix(ConvertType): Read dbtype in createConnectionParams and remove sa…
Browse files Browse the repository at this point in the history
…feguard

Signed-off-by: Nils Wenninghoff <[email protected]>
  • Loading branch information
Nils Wenninghoff authored and provokateurin committed Jan 30, 2025
1 parent 2927075 commit 3ef0490
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
9 changes: 1 addition & 8 deletions core/Command/Db/ConvertType.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,6 @@ protected function readPassword(InputInterface $input, OutputInterface $output)
}

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);

Expand Down Expand Up @@ -251,7 +244,7 @@ protected function createSchema(Connection $fromDB, Connection $toDB, InputInter

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'),
Expand Down
12 changes: 5 additions & 7 deletions lib/private/DB/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getConnection(string $type, array $additionalConnectionParams):
$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)
Expand Down Expand Up @@ -187,12 +187,10 @@ public function isValidType($type) {

/**
* 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', '')),
Expand Down Expand Up @@ -224,7 +222,7 @@ public function createConnectionParams(string $configPrefix = '', array $additio
'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',
Expand Down

0 comments on commit 3ef0490

Please sign in to comment.