From bdf7d091449f54261724ef97ca6ebda3397ed44a Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 28 Jul 2022 13:21:23 +1200 Subject: [PATCH] MNT Update Utf8TestHelper for MySQL 8.0.30 --- tests/php/ORM/Utf8/Utf8TestHelper.php | 28 +++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/php/ORM/Utf8/Utf8TestHelper.php b/tests/php/ORM/Utf8/Utf8TestHelper.php index 57379b0e8..ea6548cd0 100644 --- a/tests/php/ORM/Utf8/Utf8TestHelper.php +++ b/tests/php/ORM/Utf8/Utf8TestHelper.php @@ -23,10 +23,12 @@ class Utf8TestHelper implements TestOnly public function getUpdatedUtfCollationForCurrentDB(string $collation): string { if ($collation === 'utf8_general_ci') { - return $this->isMariaDBGte106() ? 'utf8mb3_general_ci' : 'utf8_general_ci'; + return $this->isMariaDBGte106() || $this->isMySqlGte8030() + ? 'utf8mb3_general_ci' : 'utf8_general_ci'; } if ($collation === 'utf8_unicode_520_ci') { - return $this->isMariaDBGte106() ? 'utf8mb3_unicode_520_ci' : 'utf8_unicode_520_ci'; + return $this->isMariaDBGte106() || $this->isMySqlGte8030() + ? 'utf8mb3_unicode_520_ci' : 'utf8_unicode_520_ci'; } return $collation; } @@ -45,6 +47,28 @@ class Utf8TestHelper implements TestOnly return false; } + /** + * Starting with 8.0.30, utf8mb3 is reported for the collation as well + * https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-30.html + */ + private function isMySqlGte8030(): bool + { + // Example MySQL version: 8.0.29 + if (preg_match('#^([0-9]+)\.([0-9]+)\.([0-9]+)$#', $this->getDBVersion(), $m)) { + if ((int) $m[1] >= 8) { + if ((int) $m[2] === 0) { + if ((int) $m[3] >= 30) { + return true; + } + } else { + return true; + } + } + } + return false; + } + + /** * Until MariaDB 10.5, utf8mb3 was an alias for utf8. * From MariaDB 10.6, utf8 is by default an alias for utf8mb3