From 724bc506615a12932c4061ed353b78f5a2fc531f Mon Sep 17 00:00:00 2001 From: "p.kumar" Date: Fri, 10 Dec 2021 12:17:04 +0000 Subject: [PATCH] fix install issue with db port --- .../install/store/install-view/install-view.store.ts | 3 +-- core/backend/Install/Command/LegacyInstallCommand.php | 4 ++-- core/backend/Install/LegacyHandler/InstallHandler.php | 11 ++++++++--- .../Service/Installation/InstallActionHandler.php | 7 +------ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/core/app/core/src/lib/views/install/store/install-view/install-view.store.ts b/core/app/core/src/lib/views/install/store/install-view/install-view.store.ts index 1e835f0d1..6c320e36c 100644 --- a/core/app/core/src/lib/views/install/store/install-view/install-view.store.ts +++ b/core/app/core/src/lib/views/install/store/install-view/install-view.store.ts @@ -362,8 +362,7 @@ export class InstallViewStore implements StateStore { "vname": "LBL_DBCONF_DB_PORT", "labelKey": "LBL_DBCONF_DB_PORT", "showLabel": ["*"], - "required": false, - "default": "3306" + "required": false } }, showLabel: { diff --git a/core/backend/Install/Command/LegacyInstallCommand.php b/core/backend/Install/Command/LegacyInstallCommand.php index 0f443a0f2..edb8bd28c 100644 --- a/core/backend/Install/Command/LegacyInstallCommand.php +++ b/core/backend/Install/Command/LegacyInstallCommand.php @@ -101,14 +101,14 @@ class LegacyInstallCommand extends BaseStepExecutorCommand ]; $this->inputConfig['db_port'] = [ - 'question' => new Question('Please enter the db port: ', '3306'), + 'question' => new Question('Please enter the db port: '), 'argument' => new InputOption( 'db_port', 'Z', InputOption::VALUE_REQUIRED, 'database port' ), - 'default' => '3306', + 'default' => '', 'required' => false ]; diff --git a/core/backend/Install/LegacyHandler/InstallHandler.php b/core/backend/Install/LegacyHandler/InstallHandler.php index 3e986d71f..ac4c040c2 100644 --- a/core/backend/Install/LegacyHandler/InstallHandler.php +++ b/core/backend/Install/LegacyHandler/InstallHandler.php @@ -260,9 +260,13 @@ class InstallHandler extends LegacyHandler */ public function checkDBConnection(array $inputArray): bool { + $dbHost = $inputArray["db_host"]; + $dbPort = $inputArray["db_port"]; + $hostString = !empty($dbPort) ? $dbHost . ':' . $dbPort : $dbHost; + try { new PDO( - "mysql:host=" . $inputArray["db_host"] . ":" . $inputArray["db_port"] . ";", + "mysql:host=" . $hostString . ";", $inputArray['db_username'], $inputArray['db_password'] ); @@ -286,9 +290,10 @@ class InstallHandler extends LegacyHandler $username = urlencode($inputArray['db_username'] ?? ''); $dbName = $inputArray['db_name'] ?? ''; $host = $inputArray['db_host'] ?? ''; - $port = $inputArray['db_port'] ?? '3306'; + $port = $inputArray['db_port'] ?? ''; + $hostString = !empty($port) ? $host . ':' . $port : $host; - $dbUrl = "DATABASE_URL=\"mysql://$username:$password@$host:$port/$dbName\""; + $dbUrl = "DATABASE_URL=\"mysql://$username:$password@$hostString/$dbName\""; $filesystem = new Filesystem(); try { chdir($this->projectDir); diff --git a/core/backend/Install/Service/Installation/InstallActionHandler.php b/core/backend/Install/Service/Installation/InstallActionHandler.php index d02212e39..aba45b772 100644 --- a/core/backend/Install/Service/Installation/InstallActionHandler.php +++ b/core/backend/Install/Service/Installation/InstallActionHandler.php @@ -101,10 +101,6 @@ class InstallActionHandler implements ProcessHandlerInterface $options = $process->getOptions(); - if(empty($options['payload']['db_port'])){ - $options['payload']['db_port'] = '3306'; - } - $validOptions = [ 'site_host', 'demoData', @@ -113,8 +109,7 @@ class InstallActionHandler implements ProcessHandlerInterface 'db_username', 'db_password', 'db_host', - 'db_name', - 'db_port' + 'db_name' ]; foreach ($validOptions as $validOption) {