[BUGFIX] UpgradeWizard check for utf8 is wrong 35/54835/2
authorSusanne Moog <susanne.moog@typo3.com>
Tue, 28 Nov 2017 16:06:36 +0000 (17:06 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 28 Nov 2017 19:14:21 +0000 (20:14 +0100)
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>
typo3/sysext/install/Classes/Controller/UpgradeController.php
typo3/sysext/install/Classes/Service/UpgradeWizardsService.php

index fe3dd96..d84e580 100644 (file)
@@ -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,
index 4610ea9..85ce16e 100644 (file)
@@ -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;
     }