From 3b4e6f581958bc46954d0d09cd0a62b71b38d3cc Mon Sep 17 00:00:00 2001
From: Timo Gurr <timo.gurr@gmail.com>
Date: Tue, 22 Aug 2023 13:23:38 +0200
Subject: [PATCH] [BUGFIX] Allow utf8mb3 as well for CharsetToCheck

On recent MariaDB versions >= 10.6 utf8 is an alias for utf8mb3 while
until MariaDB 10.5 utf8mb3 was an alias for utf8.

https://mariadb.com/kb/en/unicode/

Resolves: #101719
Releases: main, 12.4, 11.5
Change-Id: Ida8a5b89fd99f9ff196d496ddb34d55c9657daf5
Reviewed-by: Timo Gurr <timo.gurr@gmail.com>
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80616
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Timo Gurr <timo.gurr@gmail.com>
---
 typo3/sysext/install/Classes/Service/UpgradeWizardsService.php  | 2 +-
 .../Classes/SystemEnvironment/DatabaseCheck/Platform/MySql.php  | 2 ++
 .../reports/Classes/Report/Status/ConfigurationStatus.php       | 2 +-
 .../reports/Resources/Private/Language/locallang_reports.xlf    | 2 +-
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php b/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
index b02f4bb0fff7..1c8d1d3ea117 100644
--- a/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
+++ b/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
@@ -236,7 +236,7 @@ class UpgradeWizardsService
                 ->setMaxResults(1)
                 ->executeQuery()
                 ->fetchOne();
-            // check if database charset is utf-8, also allows utf8mb4
+            // check if database charset is utf-8, also allows utf8mb3 and utf8mb4
             $charsetOk = strpos($charset, 'utf8') === 0;
         }
         return $charsetOk;
diff --git a/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/MySql.php b/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/MySql.php
index c1fd57471070..49a52fd0603c 100644
--- a/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/MySql.php
+++ b/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/MySql.php
@@ -58,6 +58,7 @@ class MySql extends AbstractPlatform
      */
     protected $databaseCharsetToCheck = [
         'utf8',
+        'utf8mb3',
         'utf8mb4',
     ];
 
@@ -67,6 +68,7 @@ class MySql extends AbstractPlatform
      */
     protected $databaseServerCharsetToCheck = [
         'utf8',
+        'utf8mb3',
         'utf8mb4',
     ];
 
diff --git a/typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php b/typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php
index 815841b913d3..d4847fef415c 100644
--- a/typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php
+++ b/typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php
@@ -247,7 +247,7 @@ class ConfigurationStatus implements StatusProviderInterface
 
         $severity = ReportStatus::OK;
         $statusValue = $this->getLanguageService()->getLL('status_ok');
-        // also allow utf8mb4
+        // also allow utf8mb3 and utf8mb4
         if (strpos($defaultDatabaseCharset, 'utf8') !== 0) {
             // If the default character set is e.g. latin1, BUT all tables in the system are UTF-8,
             // we assume that TYPO3 has the correct charset for adding tables, and everything is fine
diff --git a/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf b/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf
index 37bab91cec77..196077714ee0 100644
--- a/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf
+++ b/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf
@@ -115,7 +115,7 @@
 				<source>Checking database character set failed, got key "%1$s" instead of "character_set_database"</source>
 			</trans-unit>
 			<trans-unit id="status_MysqlDatabaseCharacterSet_Unsupported" resname="status_MysqlDatabaseCharacterSet_Unsupported">
-				<source>Your default database uses character set "%1$s", but only "utf8" or "utf8mb4" is supported with TYPO3.</source>
+				<source>Your default database uses character set "%1$s", but only "utf8", "utf8mb3" or "utf8mb4" is supported with TYPO3.</source>
 			</trans-unit>
 			<trans-unit id="status_MysqlDatabaseCharacterSet_Ok" resname="status_MysqlDatabaseCharacterSet_Ok">
 				<source>Your default database uses utf-8. All good.</source>
-- 
GitLab