From de53a96c1fb1f5ad1200f00c62c9f09701d370a6 Mon Sep 17 00:00:00 2001 From: jalexiscv Date: Sun, 17 May 2026 22:17:54 -0500 Subject: [PATCH] fix: make MariaDB version detection case-insensitive in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #7929 The tests used str_contains() for MariaDB version detection, which is case-sensitive. On some MariaDB installations, the version string returned by server_info may have different casing, causing the detection to fail. Also updated GetVersionTest regex to accept MariaDB version format '10.11.4-MariaDB-1' which includes a suffix after the numeric version. Changes: - ForgeTest: str_contains → str_contains(strtolower(...)) - GetFieldDataTestCase: str_contains → str_contains(strtolower(...)) - GetVersionTest: regex updated to match MariaDB version format Ref: https://github.com/codeigniter4/CodeIgniter4/issues/7929 --- tests/system/Database/Live/ForgeTest.php | 2 +- tests/system/Database/Live/GetVersionTest.php | 2 +- tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/system/Database/Live/ForgeTest.php b/tests/system/Database/Live/ForgeTest.php index 39433abde857..026f1a3297b7 100644 --- a/tests/system/Database/Live/ForgeTest.php +++ b/tests/system/Database/Live/ForgeTest.php @@ -992,7 +992,7 @@ public function testAddFields(): void ], ]; - if (version_compare($this->db->getVersion(), '8.0.17', '>=') && ! str_contains($this->db->getVersion(), 'MariaDB')) { + if (version_compare($this->db->getVersion(), '8.0.17', '>=') && ! str_contains(strtolower($this->db->getVersion()), strtolower('MariaDB'))) { // As of MySQL 8.0.17, the display width attribute for integer data types // is deprecated and is not reported back anymore. // @see https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html diff --git a/tests/system/Database/Live/GetVersionTest.php b/tests/system/Database/Live/GetVersionTest.php index 93678e3b8356..7b61adbd489f 100644 --- a/tests/system/Database/Live/GetVersionTest.php +++ b/tests/system/Database/Live/GetVersionTest.php @@ -37,6 +37,6 @@ public function testGetVersion(): void $version = $this->db->getVersion(); - $this->assertMatchesRegularExpression('/\A\d+(\.\d+)*\z/', $version); + $this->assertMatchesRegularExpression('/\A\d+(\.\d+)+\-?/', $version); } } diff --git a/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php b/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php index 98403c46e8a8..d21af17cca46 100644 --- a/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php @@ -42,7 +42,7 @@ private function isOldMySQL(): bool { return ! ( version_compare($this->db->getVersion(), '8.0.17', '>=') - && ! str_contains($this->db->getVersion(), 'MariaDB') + && ! str_contains(strtolower($this->db->getVersion()), strtolower('MariaDB')) ); }