diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-11-16 11:48:04 +0100 |
---|---|---|
committer | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2023-12-07 15:45:27 +0100 |
commit | 95ea46c99c6618ead70cda69d2cf81ce05507aa8 (patch) | |
tree | 75ebd47c22b5011e9e4efd5f00713c5be759babb /apps/settings | |
parent | 7b6877b278f25f76c6e909e74ce188ba6a65e306 (diff) | |
download | nextcloud-server-95ea46c99c6618ead70cda69d2cf81ce05507aa8.tar.gz nextcloud-server-95ea46c99c6618ead70cda69d2cf81ce05507aa8.zip |
Merge SQlite warning to existing SupportedDatabase setup check
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/settings')
4 files changed, 36 insertions, 16 deletions
diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 07ab12426bb..14f7068ce59 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -401,10 +401,6 @@ Raw output return $recommendations; } - protected function isSqliteUsed() { - return str_contains($this->config->getSystemValue('dbtype'), 'sqlite'); - } - protected function getSuggestedOverwriteCliURL(): string { $currentOverwriteCliUrl = $this->config->getSystemValue('overwrite.cli.url', ''); $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT; @@ -574,8 +570,6 @@ Raw output 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), 'OpcacheSetupRecommendations' => $this->getOpcacheSetupRecommendations(), 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), - 'isSqliteUsed' => $this->isSqliteUsed(), - 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'), 'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(), 'isImagickEnabled' => $this->isImagickEnabled(), 'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(), diff --git a/apps/settings/lib/SetupChecks/SupportedDatabase.php b/apps/settings/lib/SetupChecks/SupportedDatabase.php index 7cb4820952f..5739bc17958 100644 --- a/apps/settings/lib/SetupChecks/SupportedDatabase.php +++ b/apps/settings/lib/SetupChecks/SupportedDatabase.php @@ -33,12 +33,14 @@ use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; use OCP\IDBConnection; use OCP\IL10N; +use OCP\IURLGenerator; use OCP\SetupCheck\ISetupCheck; use OCP\SetupCheck\SetupResult; class SupportedDatabase implements ISetupCheck { public function __construct( private IL10N $l10n, + private IURLGenerator $urlGenerator, private IDBConnection $connection, ) { } @@ -81,7 +83,10 @@ class SupportedDatabase implements ISetupCheck { } elseif ($databasePlatform instanceof OraclePlatform) { $version = 'Oracle'; } elseif ($databasePlatform instanceof SqlitePlatform) { - $version = 'Sqlite'; + return SetupResult::warning( + $this->l10n->t('SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend. This is particularly recommended when using the desktop client for file synchronisation. To migrate to another database use the command line tool: "occ db:convert-type".'), + $this->urlGenerator->linkToDocs('admin-db-conversion') + ); } else { return SetupResult::error($this->l10n->t('Unknown database platform')); } diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index bd3ed270cdd..a4cd6bb0a96 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -165,7 +165,6 @@ class CheckSetupControllerTest extends TestCase { 'getCurlVersion', 'isPhpOutdated', 'getOpcacheSetupRecommendations', - 'isSqliteUsed', 'isPHPMailerUsed', 'getAppDirsWithDifferentOwner', 'isImagickEnabled', @@ -214,9 +213,6 @@ class CheckSetupControllerTest extends TestCase { ->method('getOpcacheSetupRecommendations') ->willReturn(['recommendation1', 'recommendation2']); $this->checkSetupController - ->method('isSqliteUsed') - ->willReturn(false); - $this->checkSetupController ->expects($this->once()) ->method('getSuggestedOverwriteCliURL') ->willReturn(''); @@ -305,8 +301,6 @@ class CheckSetupControllerTest extends TestCase { 'codeIntegrityCheckerDocumentation' => 'http://docs.example.org/server/go.php?to=admin-code-integrity', 'OpcacheSetupRecommendations' => ['recommendation1', 'recommendation2'], 'isSettimelimitAvailable' => true, - 'isSqliteUsed' => false, - 'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion', 'appDirsWithDifferentOwner' => [], 'isImagickEnabled' => false, 'areWebauthnExtensionsEnabled' => false, diff --git a/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php b/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php index 5521bec34b5..aede25475c5 100644 --- a/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php +++ b/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php @@ -25,8 +25,11 @@ declare(strict_types=1); */ namespace OCA\Settings\Tests; +use Doctrine\DBAL\Platforms\SqlitePlatform; use OCA\Settings\SetupChecks\SupportedDatabase; +use OCP\IDBConnection; use OCP\IL10N; +use OCP\IUrlGenerator; use OCP\SetupCheck\SetupResult; use Test\TestCase; @@ -34,9 +37,33 @@ use Test\TestCase; * @group DB */ class SupportedDatabaseTest extends TestCase { + private IL10N $l10n; + private IUrlGenerator $urlGenerator; + private IDBConnection $connection; + + private SupportedDatabase $check; + + protected function setUp(): void { + parent::setUp(); + + $this->l10n = $this->getMockBuilder(IL10N::class)->getMock(); + $this->urlGenerator = $this->getMockBuilder(IUrlGenerator::class)->getMock(); + $this->connection = \OCP\Server::get(IDBConnection::class); + + $this->check = new SupportedDatabase( + $this->l10n, + $this->urlGenerator, + \OCP\Server::get(IDBConnection::class) + ); + } + public function testPass(): void { - $l10n = $this->getMockBuilder(IL10N::class)->getMock(); - $check = new SupportedDatabase($l10n, \OC::$server->getDatabaseConnection()); - $this->assertEquals(SetupResult::SUCCESS, $check->run()->getSeverity()); + $platform = $this->connection->getDatabasePlatform(); + if ($platform instanceof SqlitePlatform) { + /** SQlite always gets a warning */ + $this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity()); + } else { + $this->assertEquals(SetupResult::SUCCESS, $this->check->run()->getSeverity()); + } } } |