MysqlUnicodeSupport.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\SetupChecks;
  8. use OCP\IConfig;
  9. use OCP\IL10N;
  10. use OCP\IURLGenerator;
  11. use OCP\SetupCheck\ISetupCheck;
  12. use OCP\SetupCheck\SetupResult;
  13. class MysqlUnicodeSupport implements ISetupCheck {
  14. public function __construct(
  15. private IL10N $l10n,
  16. private IConfig $config,
  17. private IURLGenerator $urlGenerator,
  18. ) {
  19. }
  20. public function getName(): string {
  21. return $this->l10n->t('MySQL Unicode support');
  22. }
  23. public function getCategory(): string {
  24. return 'database';
  25. }
  26. public function run(): SetupResult {
  27. if ($this->config->getSystemValueString('dbtype') !== 'mysql') {
  28. return SetupResult::success($this->l10n->t('You are not using MySQL'));
  29. }
  30. if ($this->config->getSystemValueBool('mysql.utf8mb4', false)) {
  31. return SetupResult::success($this->l10n->t('MySQL is used as database and does support 4-byte characters'));
  32. } else {
  33. return SetupResult::warning(
  34. $this->l10n->t('MySQL is used as database but does not support 4-byte characters. To be able to handle 4-byte characters (like emojis) without issues in filenames or comments for example it is recommended to enable the 4-byte support in MySQL.'),
  35. $this->urlGenerator->linkToDocs('admin-mysql-utf8mb4'),
  36. );
  37. }
  38. }
  39. }