From 9cefc0a58c0c9ff292ffa7f243749121b4c3d87c Mon Sep 17 00:00:00 2001
From: Susanne Moog <susanne.moog@typo3.com>
Date: Tue, 28 Nov 2017 17:06:36 +0100
Subject: [PATCH] [BUGFIX] UpgradeWizard check for utf8 is wrong

The upgrade wizard checking for utf-8 sets a
variable called charsetOk which worked
differently on MySQL compared to other DBMS.

On MySQL it contained true if the charset was
not OK, in all other cases it was true if ok.

This is now consistently handled according to
the variable name.

Change-Id: Iee347b6c2469ad9a33e9bd4109d361dc337a63a0
Resolves: #83141
Releases: master
Reviewed-on: https://review.typo3.org/54835
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../install/Classes/Controller/UpgradeController.php       | 2 +-
 .../install/Classes/Service/UpgradeWizardsService.php      | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/install/Classes/Controller/UpgradeController.php b/typo3/sysext/install/Classes/Controller/UpgradeController.php
index fe3dd966bf59..d84e58079582 100644
--- a/typo3/sysext/install/Classes/Controller/UpgradeController.php
+++ b/typo3/sysext/install/Classes/Controller/UpgradeController.php
@@ -835,7 +835,7 @@ class UpgradeController extends AbstractController
     public function upgradeWizardsBlockingDatabaseCharsetTestAction(): ResponseInterface
     {
         $upgradeWizardsService = new UpgradeWizardsService();
-        $result = $upgradeWizardsService->isDatabaseCharsetUtf8();
+        $result = !$upgradeWizardsService->isDatabaseCharsetUtf8();
         return new JsonResponse([
             'success' => true,
             'needsUpdate' => $result,
diff --git a/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php b/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
index 4610ea904ed8..85ce16eb356f 100644
--- a/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
+++ b/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Install\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Doctrine\DBAL\Platforms\MySqlPlatform;
 use Doctrine\DBAL\Schema\Column;
 use Doctrine\DBAL\Schema\Table;
 use TYPO3\CMS\Core\Cache\DatabaseSchemaService;
@@ -210,9 +211,11 @@ class UpgradeWizardsService
      */
     public function isDatabaseCharsetUtf8(): bool
     {
+        /** @var \TYPO3\CMS\Core\Database\Connection $connection */
         $connection = GeneralUtility::makeInstance(ConnectionPool::class)
             ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
-        $isDefaultConnectionMysql = strpos($connection->getServerVersion(), 'MySQL') === 0;
+
+        $isDefaultConnectionMysql = ($connection->getDatabasePlatform() instanceof MySqlPlatform);
 
         if (!$isDefaultConnectionMysql) {
             // Not tested on non mysql
@@ -231,7 +234,7 @@ class UpgradeWizardsService
                 ->execute()
                 ->fetchColumn();
             // check if database charset is utf-8, also allows utf8mb4
-            $charsetOk = strpos($charset, 'utf8') !== 0;
+            $charsetOk = strpos($charset, 'utf8') === 0;
         }
         return $charsetOk;
     }
-- 
GitLab