From e2cd1d209c0cdc64346238f5c360334fd178c0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Tue, 24 Jun 2025 08:29:44 +0200 Subject: [PATCH 1/8] fix(db): improve port handling in DatabaseHelper --- src/N98/Util/Console/Helper/DatabaseHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/N98/Util/Console/Helper/DatabaseHelper.php b/src/N98/Util/Console/Helper/DatabaseHelper.php index 3954a3564..bfbec97a2 100644 --- a/src/N98/Util/Console/Helper/DatabaseHelper.php +++ b/src/N98/Util/Console/Helper/DatabaseHelper.php @@ -440,7 +440,7 @@ public function getMysqlClientToolConnectionString() . ' ' . '-u' . escapeshellarg($this->dbSettings['username']) . ' ' - . (isset($this->dbSettings['port']) + . (isset($this->dbSettings['port']) && is_numeric($this->dbSettings['port']) && (int)$this->dbSettings['port'] > 0 ? '-P' . escapeshellarg($this->dbSettings['port']) . ' ' : '') . (strlen($this->dbSettings['password']) ? '--password=' . escapeshellarg($this->dbSettings['password']) . ' ' : '') From 83eff945c31b5414e1800098b73867deb776c13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Tue, 24 Jun 2025 08:47:57 +0200 Subject: [PATCH 2/8] fix(db): enhance port handling in DatabaseHelper for IPv6 compatibility --- .../Util/Console/Helper/DatabaseHelper.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/N98/Util/Console/Helper/DatabaseHelper.php b/src/N98/Util/Console/Helper/DatabaseHelper.php index bfbec97a2..6c4a4d0c5 100644 --- a/src/N98/Util/Console/Helper/DatabaseHelper.php +++ b/src/N98/Util/Console/Helper/DatabaseHelper.php @@ -153,8 +153,14 @@ public function detectDbSettings(?OutputInterface $output) if (strpos($this->dbSettings['host'], '/') !== false) { $this->dbSettings['unix_socket'] = $this->dbSettings['host']; unset($this->dbSettings['host']); - } elseif (strpos($this->dbSettings['host'], ':') !== false) { - list($this->dbSettings['host'], $this->dbSettings['port']) = explode(':', $this->dbSettings['host']); + } elseif (strpos($this->dbSettings['host'], ':') !== false + && substr_count($this->dbSettings['host'], ':') === 1) { + // Only split if not IPv6 (which has multiple colons) + list($host, $port) = explode(':', $this->dbSettings['host'], 2); + $this->dbSettings['host'] = $host; + if (is_numeric($port)) { + $this->dbSettings['port'] = (int)$port; + } } } @@ -195,8 +201,13 @@ public function getConnection(?OutputInterface $output = null, bool $reconnect = if (strpos($this->dbSettings['host'], '/') !== false) { $this->dbSettings['unix_socket'] = $this->dbSettings['host']; unset($this->dbSettings['host']); - } elseif (strpos($this->dbSettings['host'], ':') !== false) { - list($this->dbSettings['host'], $this->dbSettings['port']) = explode(':', $this->dbSettings['host']); + } elseif (strpos($this->dbSettings['host'], ':') !== false && substr_count($this->dbSettings['host'], ':') === 1) { + // Only split if not IPv6 (which has multiple colons) + list($host, $port) = explode(':', $this->dbSettings['host'], 2); + $this->dbSettings['host'] = $host; + if (is_numeric($port)) { + $this->dbSettings['port'] = (int)$port; + } } } From 6fcae1c0b3f0810bb5bf4cf153654425bdf7f491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Tue, 24 Jun 2025 09:00:15 +0200 Subject: [PATCH 3/8] fix(db): update MariaDB setup in CI configuration --- .github/workflows/mage-os_nightly_test.yml | 35 ++++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/.github/workflows/mage-os_nightly_test.yml b/.github/workflows/mage-os_nightly_test.yml index 51c4af0cf..3e088806e 100644 --- a/.github/workflows/mage-os_nightly_test.yml +++ b/.github/workflows/mage-os_nightly_test.yml @@ -28,32 +28,27 @@ jobs: --health-timeout=5s --health-retries=10 + mariadb: + image: mariadb:11.4 + env: + MARIADB_ROOT_PASSWORD: root + MARIADB_DATABASE: magento + ports: + - 3306 + options: >- + --tmpfs /tmp:rw + --tmpfs /var/lib/mysql:rw + --health-cmd="mysqladmin ping -h 127.0.0.1 --silent" + --health-interval=10s + --health-timeout=5s + --health-retries=10 + steps: - name: Checkout develop branch uses: actions/checkout@v4.2.2 with: ref: develop - - uses: shogo82148/actions-setup-mysql@v1 - with: - distribution: "mariadb" - mysql-version: "11.4" - auto-start: "true" - root-password: "root" - - - name: Check MariaDB version - run: "mariadb -uroot -proot -e 'SELECT version();'" - - - name: List installed MySQL/MariaDB tools - run: | - mariadb --version || true - mariadb-dump --version || true - mysql --version || true - mysqldump --version || true - - - name: Create Magento database - run: "mariadb -uroot -proot -e 'CREATE DATABASE magento;'" - - name: Linux Setup run: ./.github/workflows/linux-setup.sh From fc15c9a0f6e08748727ca15a2c41904be08ce555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Tue, 24 Jun 2025 09:11:38 +0200 Subject: [PATCH 4/8] fix(db): update MariaDB image version and enhance db:query command tests --- .github/workflows/mage-os_nightly_test.yml | 5 +++-- tests/bats/functional_magerun_commands.bats | 23 +++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/mage-os_nightly_test.yml b/.github/workflows/mage-os_nightly_test.yml index 3e088806e..5c9ff6a26 100644 --- a/.github/workflows/mage-os_nightly_test.yml +++ b/.github/workflows/mage-os_nightly_test.yml @@ -29,12 +29,13 @@ jobs: --health-retries=10 mariadb: - image: mariadb:11.4 + image: "mariadb:11.6" env: MARIADB_ROOT_PASSWORD: root MARIADB_DATABASE: magento ports: - - 3306 + - 3306 # Standard MariaDB/MySQL port + # Options remain largely the same, health check uses mysqladmin (compatible) options: >- --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw diff --git a/tests/bats/functional_magerun_commands.bats b/tests/bats/functional_magerun_commands.bats index fb29af5c1..fa6a8d1a9 100755 --- a/tests/bats/functional_magerun_commands.bats +++ b/tests/bats/functional_magerun_commands.bats @@ -530,6 +530,18 @@ function cleanup_files_in_magento() { assert_output --partial "innodb_buffer_pool_size" } + +# ============================================ +# Command: db:query +# ============================================ + +@test "Command: db:query --format=csv" { + run $BIN "db:query" --format=csv "SELECT 1 AS foo, 2 AS bar" + assert_output --partial '"foo","bar"' + assert_output --partial '"1","2"' + assert [ "$status" -eq 0 ] +} + # ============================================ # Command: design:demo-notice # ============================================ @@ -549,17 +561,6 @@ function cleanup_files_in_magento() { # assert_output --partial "di" #} -# ============================================ -# Command: db:query -# ============================================ - -@test "Command: db:query --format=csv" { - run $BIN "db:query" --format=csv "SELECT 1 AS foo, 2 AS bar" - assert_output --partial '"foo","bar"' - assert_output --partial '"1","2"' - assert [ "$status" -eq 0 ] -} - # ============================================ # Command: dev:module:create # ============================================ From 4ef700a3b75d8ea65894061344d53c45dd260698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Tue, 24 Jun 2025 10:48:27 +0200 Subject: [PATCH 5/8] fix(db): remove tmpfs options from MariaDB setup in CI configuration --- .github/workflows/mage-os_nightly_test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/mage-os_nightly_test.yml b/.github/workflows/mage-os_nightly_test.yml index 5c9ff6a26..32b130ef1 100644 --- a/.github/workflows/mage-os_nightly_test.yml +++ b/.github/workflows/mage-os_nightly_test.yml @@ -37,8 +37,6 @@ jobs: - 3306 # Standard MariaDB/MySQL port # Options remain largely the same, health check uses mysqladmin (compatible) options: >- - --tmpfs /tmp:rw - --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping -h 127.0.0.1 --silent" --health-interval=10s --health-timeout=5s From 3835178d6fbfba8cdcdc80bc631833872d79347e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Tue, 24 Jun 2025 11:47:40 +0200 Subject: [PATCH 6/8] fix(db): update health check command for MariaDB in CI configuration --- .github/workflows/mage-os_nightly_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mage-os_nightly_test.yml b/.github/workflows/mage-os_nightly_test.yml index 32b130ef1..aea8d8730 100644 --- a/.github/workflows/mage-os_nightly_test.yml +++ b/.github/workflows/mage-os_nightly_test.yml @@ -37,7 +37,7 @@ jobs: - 3306 # Standard MariaDB/MySQL port # Options remain largely the same, health check uses mysqladmin (compatible) options: >- - --health-cmd="mysqladmin ping -h 127.0.0.1 --silent" + --health-cmd="mariadb-admin ping -uroot -proot || exit 1" --health-interval=10s --health-timeout=5s --health-retries=10 From 34acbb5977bd255de6c6fd9b59a40e2dc75a3aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Tue, 24 Jun 2025 11:51:39 +0200 Subject: [PATCH 7/8] fix(db): downgrade MariaDB image version in CI configuration --- .github/workflows/mage-os_nightly_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mage-os_nightly_test.yml b/.github/workflows/mage-os_nightly_test.yml index aea8d8730..f855e898c 100644 --- a/.github/workflows/mage-os_nightly_test.yml +++ b/.github/workflows/mage-os_nightly_test.yml @@ -29,7 +29,7 @@ jobs: --health-retries=10 mariadb: - image: "mariadb:11.6" + image: "mariadb:10.6" env: MARIADB_ROOT_PASSWORD: root MARIADB_DATABASE: magento From 090e6598b99db3fd56d94631a2bf5defd66769bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Tue, 24 Jun 2025 11:54:34 +0200 Subject: [PATCH 8/8] docs: improve port handling in database helper --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 865b6228e..a63d7ef5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ RECENT CHANGES - Imp: feat(dev:hyva:build): Add check for Hyvä theme in dev:hyva:build command (by Christian Münch) - Fix: better TTY handling in proxy command (PR #1667, issue #1422, by Christian Münch) - Fix: PHP 8.4 compatibility updates (PR #1655, issue #1654, by Christian Münch) +- Fix: Port handling in database helper (by Christian Münch) - Build: CI release workflow enhancements (PR #1657, issue #1657, by Christian Münch) 8.1.1