diff --git a/typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php b/typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php index 3800943d0802edb0688efff44b1534f46e7c4ce7..eb669582df17d82f43f70d0fe69c62912fa7a71b 100644 --- a/typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php +++ b/typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php @@ -16,12 +16,12 @@ namespace TYPO3\CMS\Reports\Report\Status; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Database\DatabaseConnection; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Registry; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\PathUtility; +use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\CMS\Lang\LanguageService; use TYPO3\CMS\Reports\Status as ReportStatus; use TYPO3\CMS\Reports\StatusProviderInterface; @@ -267,49 +267,55 @@ class ConfigurationStatus implements StatusProviderInterface } /** - * Verifies that MySQL is used. + * Checks if the default connection is a MySQL compatible database instance. * * @return bool */ protected function isMysqlUsed() { - return get_class($this->getDatabaseConnection()) == DatabaseConnection::class; + $connection = GeneralUtility::makeInstance(ConnectionPool::class) + ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME); + + return StringUtility::beginsWith($connection->getServerVersion(), 'MySQL'); } /** - * Checks the character set of the database and reports an error if it is not utf-8. + * Checks the character set of the default database and reports an error if it is not utf-8. * * @return ReportStatus */ protected function getMysqlDatabaseUtf8Status() { - $result = $this->getDatabaseConnection()->admin_query('SHOW VARIABLES LIKE "character_set_database"'); - $row = $this->getDatabaseConnection()->sql_fetch_assoc($result); - - $key = $row['Variable_name']; - $value = $row['Value']; + $connection = GeneralUtility::makeInstance(ConnectionPool::class) + ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME); + $queryBuilder = $connection->createQueryBuilder(); + $defaultDatabaseCharset = (string)$queryBuilder->select('DEFAULT_CHARACTER_SET_NAME') + ->from('information_schema.SCHEMATA') + ->where( + $queryBuilder->expr()->eq('SCHEMA_NAME', $queryBuilder->quote($connection->getDatabase())) + ) + ->setMaxResults(1) + ->execute() + ->fetchColumn(); - $message = ''; $severity = ReportStatus::OK; $statusValue = $this->getLanguageService()->getLL('status_ok'); - - if ($key !== 'character_set_database') { - $message = sprintf($this->getLanguageService()->getLL('status_MysqlDatabaseCharacterSet_CheckFailed'), $key); - $severity = ReportStatus::WARNING; - $statusValue = $this->getLanguageService()->getLL('status_checkFailed'); - } // also allow utf8mb4 - if (substr($value, 0, 4) !== 'utf8') { - $message = sprintf($this->getLanguageService()->getLL('status_MysqlDatabaseCharacterSet_Unsupported'), $value); + if (!StringUtility::beginsWith($defaultDatabaseCharset, 'utf8')) { + $message = sprintf($this->getLanguageService() + ->getLL('status_MysqlDatabaseCharacterSet_Unsupported'), $defaultDatabaseCharset); $severity = ReportStatus::ERROR; $statusValue = $this->getLanguageService()->getLL('status_wrongValue'); } else { $message = $this->getLanguageService()->getLL('status_MysqlDatabaseCharacterSet_Ok'); } - return GeneralUtility::makeInstance(ReportStatus::class, + return GeneralUtility::makeInstance( + ReportStatus::class, $this->getLanguageService()->getLL('status_MysqlDatabaseCharacterSet'), - $statusValue, $message, $severity + $statusValue, + $message, + $severity ); } @@ -362,12 +368,4 @@ class ConfigurationStatus implements StatusProviderInterface { return $GLOBALS['LANG']; } - - /** - * @return DatabaseConnection - */ - protected function getDatabaseConnection() - { - return $GLOBALS['TYPO3_DB']; - } } diff --git a/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf b/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf index ed3a68951fa537085a927aee6adea7c9a9e66356..10b5ea6a645e87e1a7d63d5d452bbfa74d96acce 100644 --- a/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf +++ b/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf @@ -109,10 +109,10 @@ <source>Checking database character set failed, got key "%1$s" instead of "character_set_database"</source> </trans-unit> <trans-unit id="status_MysqlDatabaseCharacterSet_Unsupported"> - <source>Your database uses character set "%1$s", but only "utf8" is supported with TYPO3.</source> + <source>Your default database uses character set "%1$s", but only "utf8" or "utf8mb4" is supported with TYPO3.</source> </trans-unit> <trans-unit id="status_MysqlDatabaseCharacterSet_Ok"> - <source>Your database uses utf-8. All good.</source> + <source>Your default database uses utf-8. All good.</source> </trans-unit> <trans-unit id="status_trustedHostsPattern"> <source>Trusted Hosts Pattern</source>